• Post Reply Bookmark Topic Watch Topic
  • New Topic

Database populated dataTable/table selection?

 
Robert Verdes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. I've been bashing my head on tons of posts and articles on how to add (multiple) row selection functionality to a jsf dataTable or table component populated with a database table. It just doesn't seem the same as object array populated tables, where the easy key is to add a boolean attribute to the object and you're set.
But you can't (don't want to) add a "SELECTED" column to your database table, as it will be globally visible, and sincerely seems messy.

So how do you guys do it? I tried adding a column with a checkbox, and on each check, add an unique information from the row to an array. But the checkboxes un-check every time the page is reloaded.

I've been using JSF for two months now and still haven't found a decent way to do it (hence, i've been using mostly arrays)

Thank you!
 
Bibin Zacharias
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a boolean attribute in your POJO. map that attrbute to check box. No need to add any field in database.
When you submit seperate the objects by checking the boolean attrutes wether it is selected or not. Then delete the rows from database.

 
Robert Verdes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bibin Zacharias wrote:Add a boolean attribute in your POJO. map that attrbute to check box.


Hi, thanks for the quick reply.

I'm not certain i understand which POJO you're talking about. But yes, i've added a boolean attribute called 'selected' in the JSF page (the .java). And bound it to the checkbox, and this fenomenon is happening: (i have 4 rows) when selecting 1 or 2 and hitting a dummie button (only refreshes), they deselect. when selecting 3, all 4 get selected!

I don't see how a single attribute in my java bean class would fix it, as the table rows are dinamically generated, and there would be a single value bound to all the checkboxes.
 
Robert Verdes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I've FINALLY got it. Thanks for the reply, but i've found my answer here: http://balusc.blogspot.com/2006/06/using-datatables.html#SelectMultipleRows , thanks to this forum.

So i'm using the second variant, a Map.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!