Time for action – using DataTable with multiple row selection support
In this section we will demonstrate how to select multiple user rows and disable the selected users.
Create a DataTable component with the multiple
row selection mode enabled, using the following code:
<p:dataTable var="user" value="#{adminController.users}" selection="#{adminController.selectedUsers}" rowKey="#{user.id}"> <p:column selectionMode="multiple"/> <p:column headerText="Id" width="20px;"> <h:outputText value="#{user.id}" /> </p:column> <p:column headerText="Email" > <h:outputText value="#{user.emailId}" /> </p:column> <f:facet name="footer"> <p:commandButton value="Disable" actionListener="#{adminController.disableSelectedUsers}"/> </f:facet> </p:dataTable>