Use rich:datascroller for rich:dataTable pagination

rich:datascroller and rich:dataTable

rich:dataTable tag is the RichFaces version for datatable component which has few extra features on look and feel.One of the difficulty JSF developers is creating good pagination for the data dsiplayed using rich:datatable. To resole this problem, RichFaces tags library provides rich:datascroller component which can display the automatic paginations based on data populated using rich:dataTable.

also read:

This tips shows very basic working example using rich:datascroller.for attribute in the rich:datascroller is used for mapping to corresponding rich:dataTable. rows attribute in the dataTable used for displaying the number of rows in each page. There is many attributes in rich:datascroller to manipulate the look and the way it is diplaying data.


<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>
<%@ taglib prefix="rich" uri="" %>
<%@ taglib prefix="a4j" uri=""%>
                <rich:datascroller for="sampleData" maxPages="10"/>
                <rich:dataTable id="sampleData" value="#{richBean.employees}" var="loc" rows="10">
                        <h:outputText value="#{loc.empId}"/>
                        <h:outputText value="#{loc.empName}"/>
                        <h:outputText value="#{loc.dept}"/>


import java.util.ArrayList;
import java.util.List;

 * source :
public class JavaBeatRichfacesBean {
    private List<employee> employees;

    public List<employee> getEmployees() {
        this.employees = new ArrayList<employee>();
        Employee employee = null;
        for (int i = 0;i<50;i++)
            employee = new Employee();
            employee.setEmpName("Name : " + i);
        return employees;

    public void setEmployees(List<employee> employees) {
        this.employees = employees;



<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2"



About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

  • Venkatesh

    Hi Krishna,
    If i use binding attribute in for getting row then the border lines of table became as hide. After clicking Refresh only it is displaying the border line.
    –>I need with binding attribute.
    Please give reply.