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 – creating ContextMenu for DataTable

In this section, we will take a look at how we can integrate ContextMenu with DataTable, so that we will see a custom menu instead of a browser menu, when you right-click on any DataTable row, by performing the following steps:

  1. Create a DataTable component with the single row selection mode:
    <p:dataTable id="usersTbl" var="user" value="#{adminController.users}" style="width: 300px;" paginator="true" rows="5" selectionMode="single" selection="#{adminController.selectedUser}" rowKey="#{user.id}" > <f:facet name="header"> List of Users </f:facet> <p:column headerText="Id" width="20px;"> <h:outputText value="#{user.id}" /> </p:column> <p:column headerText="Email" > <h:outputText value="#{user.emailId}" ...

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