wood burning stoves 2.0*
The moose likes JSF and the fly likes selectBooleanCheckbox - How do I know which checkbox am I selecting? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "selectBooleanCheckbox - How do I know which checkbox am I selecting?" Watch "selectBooleanCheckbox - How do I know which checkbox am I selecting?" New topic
Author

selectBooleanCheckbox - How do I know which checkbox am I selecting?

Thang Pham
Ranch Hand

Joined: Jan 21, 2009
Posts: 35
Let say that my JSF file has 3 or more selectBooleanCheckbox, how can I know which checkbox I am selecting. If I do this

it only tell me a state of a checkbox is selected or not, but does not tell me which one
Max Katz
Ranch Hand

Joined: Aug 03, 2009
Posts: 72
You can use ActionListener to determine which component was clicked.


Blog: http://mkblog.exadel.com
HTML Prototypes: http://gotiggr.com
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

I am confused here. SelectBooleanCheckbox is a JSF control that renders a checkbox that displays the current value of a boolean property on a backing bean and permits that property to be changed by checking the checkbox on or off.

"Which checkbox" doesn't apply, because SelectBooleanCheckbox IS the checkbox. So It's whichever checkbox you checked. There's no possible way to confuse it.

It almost sounds like you're thinking more of a Radio button control set where there are multiple controls (radio buttons) which select a value from an integer property in a backing bean.


Customer surveys are for companies who didn't pay proper attention to begin with.
Thang Pham
Ranch Hand

Joined: Jan 21, 2009
Posts: 35
it more like a shopping cart. You have a whole bunch of items, somes you like, somes you dont. You checked on those you like and click checkout. At the backend, you kind of need to you which checkbox, they click. Now if there are only two or three checkbox, then I can have boolean variable that associate with those checkbox, but since I load these from the database, the number of items are unknown, meaning that the number of checkbox are unknown till runtime. Now, then I have a problem determine which checkbox, they select. It more like I run into design problem, rather than anything else. Anyway, I figure out the way to do it. Thanks anyway
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

Thang Pham wrote:it more like a shopping cart. You have a whole bunch of items, somes you like, somes you dont. You checked on those you like and click checkout. At the backend, you kind of need to you which checkbox, they click. Now if there are only two or three checkbox, then I can have boolean variable that associate with those checkbox, but since I load these from the database, the number of items are unknown, meaning that the number of checkbox are unknown till runtime. Now, then I have a problem determine which checkbox, they select. It more like I run into design problem, rather than anything else. Anyway, I figure out the way to do it. Thanks anyway


I have such an app. The shopping cart is displayed as rows in a dataTable. Each row item in its datamodel includes a boolean property that indicates whether that item was selected via that row's selection checkbox.
Thang Pham
Ranch Hand

Joined: Jan 21, 2009
Posts: 35
yeah, that how I intend to fix it by introducing a boolean variables inside my data model. Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: selectBooleanCheckbox - How do I know which checkbox am I selecting?
 
Similar Threads
getting selected row in datatable
selectBooleanCheckbox embedded in datatable
Add Checkbox in JOptionPane
actionlistener for selectBooleanCheckbox doubt?
Retaining checked value in selectBooleanCheckbox on enabling