To keep dataTable header sticky to the top of its parent container while scrolling vertically, we need to add stickyHeader="true" attribute in our dataTable element.
Creating managed bean
@ManagedBean
@RequestScoped
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
.............
}