I would like to have a table of orders grouped by customers. From this table, the user can select several booking options for billing. Therefore, I am trying to use SubTable to group, however, I am not sure how to implement the selection functionality. Apparently, the subtable does not allow the selection attribute, and if I set the selection attribute in the parent DataTable, I donβt know how to select rowKey.
This is my attempt:
<p:dataTable style="border: 0px;" value='#{clientController.allClients}' var='client' rowKey="#{item.id}" selectionMode="multiple" selection="#{bookingController.bookingsToBill}"> <p:subTable value='#{client.billableBookings}' var='item'> <f:facet name="header"> <h:outputText style="font-weight:bold;" value="#{client.name}" /> </f:facet> <p:column> <f:facet name="header"> <h:outputText value="Booking"/> </f:facet> <h:outputText value="#{item.title}"/> </p:column> </p:subTable> </p:dataTable>
Well, this leads to the following error when submitting a selection:
java.lang.NullPointerException java.lang.reflect.Array.newArray(Native Method) java.lang.reflect.Array.newInstance(Array.java:52) org.primefaces.component.datatable.DataHelper.decodeMultipleSelection(DataHelper.java:238) org.primefaces.component.datatable.DataHelper.decodeSelection(DataHelper.java:224) org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:64) javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787) javax.faces.component.UIData.processDecodes(UIData.java:1162) org.primefaces.component.datatable.DataTable.processDecodes(DataTable.java:531) javax.faces.component.UIForm.processDecodes(UIForm.java:225) javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176) javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176) javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933) com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
Is multiple selection supported for data tables with subtests? If so, how to do it right? If not, in which case would you suggest achieving a similar result?
I use: Primefaces 3.1.1 - Mojarra JSF 2.1 - Tomcat 6.0.14
source share