O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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>

What just ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required