@ManagedBean @ViewScoped public class EmployeeBean { private List<Employee> employeeList = new ArrayList<>(); ............. public List<Employee> getEmployeeList () { return employeeList; } }
public class Employee { private long id; private String name; private String phoneNumber; private String address; //getters/setters ............. }
<p:dataTable var="employee" value="#{employeeBean.employeeList}"> <p:column headerText="Id" sortBy="#{employee.id}"> <h:outputText value="#{employee.id}"/> </p:column> <p:column headerText="Name" sortBy="#{employee.name}"> <h:outputText value="#{employee.name}"/> </p:column> <p:column headerText="Phone Number" sortBy="#{employee.phoneNumber}"> <h:outputText value="#{employee.phoneNumber}"/> </p:column> <p:column headerText="Address" sortBy="#{employee.address}"> <h:outputText value="#{employee.address}"/> </p:column> </p:dataTable>
To try examples, run embedded tomcat (configured in pom.xml of example project below):
mvn tomcat7:run-war
Dependencies and Technologies Used: