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"

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!