i want to select many items from a list of Utilisateur(Users) but the checkbox is repeated for each line eg:i have 2 Users in Db and this is why it appears that two checkbox on the values of a for each Users for each line of datatble
this is my xhtml file:
<p:dataTable id="dta" value="#{UtilisateurComponent.listUtilisateurs()}" var="current" rows="15" paginator="true" paginatorPosition="bottom">
<p:column>
<h:selectManyCheckbox id="selectUser" value="#{ProjetComponent.projet.utilisateurs}" >
<f:selectItems value="#{UtilisateurComponent.listUtilisateurs()}" var="utilisateurs" itemValue="#{utilisateurs.iduser}" itemLabel=""/>
</h:selectManyCheckbox>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{utilisateurmsgs['utilisateur.datederniereconnexion.title']}" />
</f:facet>
<h:outputText value="#{current.datederniereconnexion}" converter="dateTimeConverterForCalendar" />
</p:column>
and this the generated form
This because you did this:
<f:selectItems value="#{UtilisateurComponent.listUtilisateurs()}" var="utilisateurs" itemValue="#{utilisateurs.iduser}" itemLabel=""/>
f:selectItems - It get the data from a list and create the checkboxes by the list size.
You need to do something like this, Use the var in the p:dataTable.
<f:selectItem itemValue="#{utilisateurs.iduser}" itemLabel="blabla"/>
Notice also that i have changed selectItems to selectItem.
Look at this link.. You have exactly the example you want in the bottom.. Table with check boxes http://www.primefaces.org/showcase/ui/data/datatable/selection.xhtml
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.