• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Thang Pham
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use ActionListener to determine which component was clicked.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18100
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Thang Pham
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18100
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, that how I intend to fix it by introducing a boolean variables inside my data model. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic