p:dataTable Checkbox Selection

UI Components for JSF
Post Reply
keuller
Posts: 7
Joined: 06 Nov 2010, 21:47

06 Nov 2010, 22:03

Hi,

I'm using a Primefaces 2.2.RC1 with Mojarra 2.0.3 and Spring to developer an simple application. When I create an object into database using p:dataTable with checkbox selection mode it works fine (all objects checked by user is saved), saving all data on database. But when I load objets from database how can I display the items that was selected before ?

My snippet code:

Code: Select all

List<AcaoHelper> acoes = getAcoes();
   List<AcaoHelper> selected = new ArrayList<AcaoHelper>();
  for(AcaoHelper hlp : acoes)
  {
       if (hlp.getChecked().booleanValue())
           selected.add(hlp);
  }
selectedItems = selected.toArray(new AcaoHelper[]{});
When this code is called selectedItems array contains 6 elements that was selected before, but its aren't displayed checked on p:dataTable. In my acoes object has a full list that is used to display data on p:dataTable. All data are displayed correctly, but any item is checked.

Anyone can help me ?

Regards.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Nov 2010, 22:18

Have you implemented equals method for your domain object?

keuller
Posts: 7
Joined: 06 Nov 2010, 21:47

06 Nov 2010, 22:48

Thanks Cagatay!

Sorry, its was primary mistake. ;)

Works fine.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests