myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rafa PĂ©rez" <raja...@gmail.com>
Subject Re: [Trinidad] Default selection for Table
Date Fri, 16 Nov 2007 09:34:15 GMT
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
>
>

Mime
View raw message