Note that there are some explanatory texts on larger screens.

plurals
  1. POcheckbox datatable primefaces doesn't working
    primarykey
    data
    text
    <p>the checkbox datatable of primefaces library doesn't work for me, I tried to make the same code as the showcase of primefaces but when I check some rows and I click on the view button the selectedCars[] contains 0 rows : here is my xhtml page : </p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- To change this template, choose Tools | Templates and open the template in the editor. --&gt; &lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"&gt; &lt;h:head&gt; &lt;title&gt;TODO supply a title&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form id="form"&gt; &lt;p:dataTable id="multiCars" var="car" value="#{fortest.mediumCarsModel}" paginator="true" rows="10" selection="#{fortest.selectedCars}"&gt; &lt;f:facet name="header"&gt; Checkbox Based Selection &lt;/f:facet&gt; &lt;p:column selectionMode="multiple" style="width:18px" /&gt; &lt;p:column headerText="id"&gt; #{car.id} &lt;/p:column&gt; &lt;p:column headerText="date envoi"&gt; #{car.dateEnvoi} &lt;/p:column&gt; &lt;p:column headerText="decision" &gt; #{car.decision} &lt;/p:column&gt; &lt;f:facet name="footer"&gt; &lt;p:commandButton id="multiViewButton" value="View" icon="ui-icon-search" update=":form:displayMulti" oncomplete="multiCarDialog.show()"/&gt; &lt;/f:facet&gt; &lt;/p:dataTable&gt; &lt;p:dialog id="multiDialog" header="Car Detail" widgetVar="multiCarDialog" height="300" showEffect="fade" hideEffect="explode"&gt; &lt;p:dataList id="displayMulti" value="#{fortest.selectedCars}" var="selectedCar"&gt; id : #{selectedCar.id}, dateEnvoi #{selectedCar.dateEnvoi} &lt;/p:dataList&gt; &lt;/p:dialog&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>and here is my managed-Bean : </p> <pre><code> @ManagedBean @SessionScoped public class fortest implements Serializable { private Commande[] selectedCars; private dortestDataModel mediumCarsModel; utilisateursHelper uh; /** * Creates a new instance of fortest */ public fortest() { uh = new utilisateursHelper(); mediumCarsModel = new dortestDataModel(uh.getAllCommandes()); } public void setSelectedCars(Commande[] selectedCars) { System.out.println("alors je suis donc la size : "+selectedCars.length); this.selectedCars = selectedCars; } public Commande[] getSelectedCars() { return selectedCars; } public dortestDataModel getMediumCarsModel() { return mediumCarsModel; } } </code></pre> <p>and here is my dataModel : </p> <pre><code> public class dortestDataModel extends ListDataModel&lt;Commande&gt; implements SelectableDataModel&lt;Commande&gt; { utilisateursHelper uh; public dortestDataModel() { } public dortestDataModel(List&lt;Commande&gt; data) { super(data); uh = new utilisateursHelper(); } @Override public Commande getRowData(String rowKey) { //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data List&lt;Commande&gt; cars = (List&lt;Commande&gt;) uh.getAllCommandes(); for(Commande car : cars) { if(car.getId().equals(rowKey)) return car; } return null; } @Override public Object getRowKey(Commande car) { return car.getId(); } } </code></pre> <p>do you have any idea, thank you in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload