Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Checkboxes in a Data Table  RSS feed

 
Dan Howard
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've been working through jsf using Sun Studio Creator and I've able to get my web application running quite well but I'm stuck on how to use checkboxes in a data table. I have a list from a rowset and I'd like the user to be able to select certain rows to perform an operation (say delete).

I found one thread about this on the java forums:
Java Forums (checkbox in data table)

But I still don't get how it works. Has anyone done this? Is there an example out there somewhere?

TIA
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but I'm stuck on how to use checkboxes in a data table


Okey, can you exlain me why are you stucked?
are checkboxes not appearing, as you want them to be, inside the datatable or not laying out properly or something else?
 
Dan Howard
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, what I mean is: How do you have checkboxes in a data table so that the user can select multiple rows and then submit for some kind of operation on those selections?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the component "h:selectBooleanCheckbox". Bind it with a backing beans method.

the link you provided, has this example.


Now remember, each rowBean in your backing bean's collection object should have an unique identifier. And this unique id will form the id of the component :
<h:selectboolean_checkbox id="#{mailBean.unique_id}"/ value="#{mailBean.selected}"/>

Now, based on the selected checkbox you can easily perform the operation you want to.

Another approach would be to use hiddenParam in each row. When a person selects any checkbox, set the corresponding hiddenparam with some value. and hence you can find ot which bean was selected.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!