Richfaces datatable example

Important notice: Richfaces framework reached End of Life in 2016. Therefore, you cannot expect fixes or enhancements unless you fork the project and upgrade yourself the framework.
We recommend reading these guidelines, if you want to modernize your Richfaces application: How to migrate Richfaces Web applications to another Web UI

The Datatable is used to show  tabular data. Additional to the standard <h:dataTable>, this component enables row and column spans for columns, a flexible layout for a header and a footer.

DataTable supports “master-detail” pattern and allows to show the combination of a master table and detail sub-tables.

The following example shows a rich:dataTable component in use:

<ui:composition xmlns=""

            <rich:panel header="Richfaces dataTable">
                <rich:dataTable value="#{TaskListBean.dataList}" var="dataItem"
                    rows="4" columnClasses="50,100,100,100"

                    <f:facet name="caption">
                        <h:outputText value="This is the caption" />

                    <f:facet name="header">
                        <h:outputText value="Trouble Ticket Systems" />

                    <rich:column colspan="4">
                        <h:outputText value="Trouble Tickets opened" />

                        <f:facet name="header">Ticket Id</f:facet>
                        <h:outputText value="#{dataItem.taskInstanceId}" />

                        <f:facet name="header">Status</f:facet>
                        <h:outputText value="#{dataItem.taskNode}" />

                        <f:facet name="header">Actor</f:facet>
                        <h:outputText value="#{dataItem.actorId}" />

                        <f:facet name="header">Description</f:facet>
                        <h:outputText value="#{dataItem.description}" />

                    <f:facet name="footer">
                        <h:outputText value="This is the footer" />
                    </f:facet />



The view needs a Backing bean to hold the Datalist of objects.

package com.sample;

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


public class TaskListBean   {
    private ArrayList dataList;
    public void loadDataList() {     
        dataList = new ArrayList();
        TaskListData data1 = new TaskListData();
        data1.setActorId("Willy smith");
        data1.setTaskNode("In Charge");
        data1.setDescription("CR 123456");

        TaskListData data2 = new TaskListData();
        data2.setActorId("Frank Sinatra");
        data2.setDescription("CR 654321");


    public List <TaskListData> getDataList() {        
        return dataList;


package com.sample;

public class TaskListData {
    private String taskNode;
    private long taskInstanceId;
    private String actorId;
    private String description;
    public String getActorId() {
     return actorId;
    public void setActorId(String actorId) {
     this.actorId = actorId;
    public String getTaskNode() {
     return taskNode;
    public void setTaskNode(String currentNode) {
     this.taskNode = currentNode;
    public String getDescription() {
     return description;
    public void setDescription(String description) {
     this.description = description;
    public long getTaskInstanceId() {
     return taskInstanceId;
    public void setTaskInstanceId(long taskInstanceId) {
     this.taskInstanceId = taskInstanceId;

As you can see the dataList holds a couple of TaskListData objects, which are diplayed in the view.

JSF 1.X users: You need to register the Bean into facesconfig.xml instead of using the @ManagedBean annotation


This is the datatable created:
richfaces datatable example

RichDatatable component is similar to the standard JSF Datatable: in this sample you defined two styles (row1,row2) which will be used to alternate the colour of the single rows. Also you define the width of the single columns with columnClasses and the background when you move Over/out with the mouse.

<rich:dataTable value="#{TaskListBean.dataList}" var="dataItem"
                      rowClasses="row1, row2" id="taskList"  rows="4"

Notice at the bottom the datascroller which will be used to scroll between items when the items are more then the “rows” field of the datatable.

<rich:datascroller align="left" for="taskList" maxPages="20" />