Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 36815 invoked from network); 16 Nov 2007 09:34:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Nov 2007 09:34:50 -0000 Received: (qmail 64123 invoked by uid 500); 16 Nov 2007 09:34:32 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 64090 invoked by uid 500); 16 Nov 2007 09:34:32 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 64079 invoked by uid 99); 16 Nov 2007 09:34:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 01:34:32 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rajalin@gmail.com designates 209.85.198.190 as permitted sender) Received: from [209.85.198.190] (HELO rv-out-0910.google.com) (209.85.198.190) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 09:34:22 +0000 Received: by rv-out-0910.google.com with SMTP id c27so586990rvf for ; Fri, 16 Nov 2007 01:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=0bXgRwu+gdDKtE6JaB4mNkIH7vPFv0rppNXsW16fAzg=; b=W9vRBqERBI3X/mVWTl3Erj8hybsxeSQgLHwUsCEXK/t12J+3mjGq96LCg2Fbm4hhr3kn1k+lUF0qBF8Fta4N/SRl+k+pG4nhKW4eMHNuzB3CYBb//B/JBYnNtopLjvr/k9yhHQyT7MxU4zoM+JnIa1HzteSTb8g3R9EazJNAlFU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=GwXh6AkG4quhPff6hik5VZEK+0kKlTcJ4eCgOrBKF2Y+l6C7er5e4umy+MqTRAvjczkQXFAE89DfOmOLTkzlxiaNjrRL/OLMB/waT6Y4qVo4kQgi9iES5ZRzB25H70I8QMUNeQGdsrxGgXxWeRMPiexD0ZDoYL2STuo91sQxGHk= Received: by 10.140.251.1 with SMTP id y1mr531673rvh.1195205656015; Fri, 16 Nov 2007 01:34:16 -0800 (PST) Received: by 10.141.22.3 with HTTP; Fri, 16 Nov 2007 01:34:15 -0800 (PST) Message-ID: Date: Fri, 16 Nov 2007 10:34:15 +0100 From: "=?ISO-8859-1?Q?Rafa_P=E9rez?=" To: "MyFaces Discussion" Subject: Re: [Trinidad] Default selection for Table In-Reply-To: <200711151739.21506.c.curtneyjacobs@comcast.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_285_33442137.1195205655966" References: <200711151739.21506.c.curtneyjacobs@comcast.net> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_285_33442137.1195205655966 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, You have at least two options: a) Link the table's selection state to the controller. @Name("controlador") public class Controller { .. RowKeySet seleccion = new RowKeySetImpl; //with its get & set .. } and at you jsp: ... By addign or deleting an entry in this property, you are selecting or unselecting the proper row in the table's CollectionModel. If you have defined an action on pages.xml, you may perform this operation in that method. Or if you only want the preselection to be made, you may modify the selection state in your @Create. b) You may binding your table to a property in your bean. Thus, if you have a class like @Name("controlador") public class Controller { .. CoreTable tabla; //with its get & set .. } you just need to set ... This way, you can access the table and handle its selection. On Nov 16, 2007 2:39 AM, Curtney Jacobs wrote: > Greetings everyone! > > I have a table (with rowSelection="single") that is pre -populated with > data > and I would like a default row to be selected. How can I do that? > > I am using seam to inject the table component > > @In (value="#{uiComponent['postalAddressForm:postalAddressTable']}", > required=false) > private UIComponent uiComponent; > > however, when I try to do the following I am getting a > NullPointerException: > UIXTable table = (UIXTable)uiComponent; > table.setRowKey(contactMethod()); > > My thinking is I get this error because the table has not been rendered > yet, > thus injecting the component produces the exception. > > > All suggestions are welcomed. > > Curtney > > ------=_Part_285_33442137.1195205655966 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi,

You have at least two options:

a) Link the table's selection state to the controller.
@Name("controlador")
public class Controller {
..

RowKeySet seleccion = new RowKeySetImpl;
//with its get & set
..
}

and at you jsp:

<tr:table rowSelection="single" selectedRowKeys="#{controlador.seleccion}">
...
</tr:table>

By addign or deleting an entry in this property, you are selecting or unselecting the proper row in the table's CollectionModel. If you have defined an action on pages.xml, you may perform this operation in that method. Or if you only want the preselection to be made, you may modify the selection state in your @Create.

b) You may binding your table to a property in your bean. Thus, if you have a class like

@Name("controlador")
public class Controller {
..

CoreTable tabla;
//with its get & set
..
}

you just need to set

<tr:table binding="#{controlador.tabla}">
...
</tr:table>

This way, you can access the table and handle its selection.

On Nov 16, 2007 2:39 AM, Curtney Jacobs <c.curtneyjacobs@comcast.net> wrote:
Greetings everyone!

I have a table (with rowSelection="single") that is pre -populated with data
and I would like a default row to be selected. How can I do that?

I am using seam to inject the table component

 @In (value="#{uiComponent['postalAddressForm:postalAddressTable']}",
required=false)
   private UIComponent uiComponent;

however,  when I try to do the following I am getting a NullPointerException:
UIXTable table = (UIXTable)uiComponent;
                               table.setRowKey(contactMethod());

My thinking is I get this error because the table has not been rendered yet,
thus injecting the component produces the exception.


All suggestions are welcomed.

Curtney


------=_Part_285_33442137.1195205655966--