Is there a way to detect which checkbox is selected?

UI Components for JSF
Post Reply
KingdomHeart
Posts: 280
Joined: 25 Jun 2010, 01:18

14 Jul 2010, 22:38

I develop something like a shopping cart. I can select multiple items (by clicking on the checkbox next to that item) and add them to a list. How can I know which checkbox I am selecting. If I do this

Code: Select all

   
<h:selectBooleanCheckbox value="#{document.checked}"/>
 
it only tell me a state of a checkbox is selected or not, but does not tell me which one. Remember the number of items is unknown until runtime since I load them from a datasource, meaning I dont know how many check box there are.

Mojarra 2.1.10, Glassfish 3.1, Tomcat 7, Primeface 3.3.1
IE 6-8, FireFox 10-13
MAC OSX Lion, Windows XP, 7

lmmoreira
Posts: 60
Joined: 08 Jul 2010, 14:15

15 Jul 2010, 01:24

Don't you want to use this instead?

<h:selectManyCheckbox id="cars"
value="#{carsBean.car}">
<f:selectItems
value="#{carBean.carList}"/>
</h:selectManyCheckbox>
From http://www.exadel.com/tutorial/jsf/jsftags-guide.html
Tomcat 7 + jsf-api - 2.0.3-SNAPSHOT + Primefaces 2.1

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

15 Jul 2010, 10:06

Do you need it on client-side? I can provide a client-side solution with jQuery if you need.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

maya
Posts: 25
Joined: 23 Aug 2010, 13:44

12 Oct 2010, 10:55

Hi Oleg


I need client side implementaion of checkboxs with it should support pagination concept ...

timotius_pamungkas
Posts: 117
Joined: 19 May 2010, 03:50

13 Oct 2010, 03:19

@Oleg

Hi oleg, do you mind to share your workaround code here? It might be useful for me too. Thanks a lot
Tomcat 7.0.25
Mojarra 2.1.6
Primefaces 3.1, 3.2
Firefox 10 and IE 7/IE 8

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests