JBoss.orgCommunity Documentation

Chapter 9. Tables and grids

9.1. <a4j:repeat>
9.1.1. Basic usage
9.1.2. Limited views and partial updates
9.1.3. Reference data
9.2. <rich:dataTable>
9.2.1. Basic usage
9.2.2. Customizing the table
9.2.3. Partial updates
9.2.4. JavaScript API
9.2.5. Reference data
9.2.6. Style classes and skin parameters
9.3. <rich:column>
9.3.1. Basic usage
9.3.2. Spanning columns
9.3.3. Spanning rows
9.3.4. Reference data
9.4. <rich:columnGroup>
9.4.1. Complex headers
9.4.2. Reference data
9.5. <rich:collapsibleSubTable>
9.5.1. Basic usage
9.5.2. Expanding and collapsing the sub-table
9.5.3. Reference data
9.5.4. Style classes
9.5.5. <rich:collapsibleSubTableToggler>
9.6. <rich:extendedDataTable>
9.6.1. Basic usage
9.6.2. Table appearance
9.6.3. Extended features
9.6.4. JavaScript API
9.6.5. Reference data
9.6.6. Style classes and skin parameters
9.7. <rich:dataGrid>
9.7.1. Basic usage
9.7.2. Customizing the grid
9.7.3. Partial updates
9.7.4. Reference data
9.7.5. Style classes and skin parameters
9.8. <rich:list>
9.8.1. Basic usage
9.8.2. Type of list
9.8.3. Bullet and numeration appearance
9.8.4. Customizing the list
9.8.5. Reference data
9.8.6. Style classes and skin parameters
9.9. <rich:dataScroller>
9.9.1. Basic usage
9.9.2. Appearance and interactivity
9.9.3. JavaScript API
9.9.4. Reference data
9.9.5. Style classes and skin parameters
9.10. Table filtering
9.10.1. Basic filtering
9.10.2. External filtering
9.11. Table sorting
9.11.1. External sorting

This chapter covers all components related to the display of tables and grids.

The <a4j:repeat> component is used to iterate changes through a repeated collection of components. It allows specific rows of items to be updated without sending Ajax requests for the entire collection. The <a4j:repeat> component forms the basis for many of the tabular components detailed in Chapter 9, Tables and grids.

The <a4j:repeat> component uses other attributes common to iteration components, such as the first attribute for specifying the first item for iteration, and the rows attribute for specifying the number of rows of items to display.

Specific cells, rows, and columns can be updated without sending Ajax requests for the entire collection. Components that cause the change can specify which part of the table to update through the render attribute. The render attribute specifies which part of a table to update:

Alternatively, keywords can be used with the render attribute:

The <rich:dataTable> component is used to render a table, including the table's header and footer. It works in conjunction with the <rich:column> and <rich:columnGroup> components to list the contents of a data model.

The first attribute specifies which item in the data model to start from, and the rows attribute specifies the number of items to list. The header, footer, and caption facets can be used to display text, and to customize the appearance of the table through skinning. demonstrates a simple table implementation.


For details on filtering and sorting data tables, refer to Section 9.10, “Table filtering” and Section 9.11, “Table sorting”.

Table 9.1. Style classes (selectors) and corresponding skin parameters

Class (selector)Skin ParametersMapped CSS properties
.rf-dt

This class defines styles for the table.

tableBackgroundColor

background-color

tableBorderWidth

border-left-width, border-top-width

tableBorderColor

border-left-color, border-top-color

.rf-dt-cap

This class defines styles for the table caption.

No skin parameters.
.rf-dt-r

This class defines styles for a table row.

No skin parameters.
.rf-dt-fst-r

This class defines styles for the first row in a table.

No skin parameters.
.rf-dt-c

This class defines styles for a table cell.

tableBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dt-nd

This class defines styles for a node.

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dt-hdr

This class defines styles for a table header.

No skin parameters.
.rf-dt-hdr-fst

This class defines styles for the first header.

No skin parameters.
.rf-dt-hdr-c

This class defines styles for a header cell.

tableHeaderBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

tableHeaderTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dt-shdr

This class defines styles for a table sub-header.

No skin parameters.
.rf-dt-shdr-fst

This class defines styles for the first sub-header.

No skin parameters.
.rf-dt-shdr-c

This class defines styles for a sub-header cell.

tableHeaderBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

tableHeaderTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dt-ftr

This class defines styles for a table footer.

No skin parameters.
.rf-dt-ftr-fst

This class defines styles for the first footer.

No skin parameters.
.rf-dt-ftr-c

This class defines styles for a footer cell.

tableFooterBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dt-sftr

This class defines styles for a table sub-footer.

No skin parameters.
.rf-dt-sftr-fst

This class defines styles for the first sub-footer.

No skin parameters.
.rf-dt-sftr-c

This class defines styles for a sub-footer cell.

tableFooterBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size


The <rich:column> component facilitates columns in a table. It supports merging columns and rows, sorting, filtering, and customized skinning.

The <rich:columnGroup> component combines multiple columns in a single row to organize complex parts of a table. The resulting effect is similar to using the breakBefore attribute of the <rich:column> component, but is clearer and easier to follow in the source code.

The <rich:columnGroup> can also be used to create complex headers in a table. Example 9.6, “Complex headers using column groups” and the resulting Figure 9.5, “Complex headers using column groups” demonstrate how complex headers can be achieved.

Example 9.6. Complex headers using column groups


The <rich:collapsibleSubTable> component acts as a child element to a <rich:dataTable> component. It allows sections of a table to be grouped into collapsible sections. The <rich:collapsibleSubTable> component works with the <rich:collapsibleSubTableToggler> component, which allows the user to expand and collapse the sub tables.

The <rich:collapsibleSubTable> component requires the same basic attributes as the <rich:dataTable> component. The value attribute points to the collection, and the var attribute specifies a variable to use when iterating through the collection.

In addition, the <rich:collapsibleSubTable> component typically needs a corresponding <rich:collapsibleSubTableToggler> component to allow expanding and collapsing. Declare the id identifier on the <rich:collapsibleSubTable> element so that the <rich:collapsibleSubTableToggler> component can reference it. Refer to Section 9.5.5, “<rich:collapsibleSubTableToggler>” for details on the <rich:collapsibleSubTableToggler> component.

Example 9.7. Basic usage


<rich:dataTable value="#{carsBean.inventoryVendorLists}" var="list">
   <f:facet name="header">
      <rich:columnGroup>
         <rich:column colspan="6">
            <h:outputText value="Cars marketplace" />
         </rich:column>
         <rich:column breakRowBefore="true">
            <h:outputText value="Model" />
         </rich:column>
         <rich:column>
            <h:outputText value="Price" />
         </rich:column>
         <rich:column>
            <h:outputText value="Mileage" />
         </rich:column>
         <rich:column>
            <h:outputText value="VIN Code" />
         </rich:column>
         <rich:column>
            <h:outputText value="Items stock" />
         </rich:column>
         <rich:column>
            <h:outputText value="Days Live" />
         </rich:column>
      </rich:columnGroup>
   </f:facet>
   <rich:column colspan="6">
      <rich:collapsibleSubTableToggler for="sbtbl" />
      <h:outputText value="#{list.vendor}" />
   </rich:column>
   <rich:collapsibleSubTable value="#{list.vendorItems}" var="item" id="sbtbl"
      expandMode="client">
      <rich:column>
         <h:outputText value="#{item.model}" />
      </rich:column>
      <rich:column>
         <h:outputText value="#{item.price}" />
      </rich:column>
      <rich:column>
         <h:outputText value="#{item.mileage}" />
      </rich:column>
      <rich:column>
         <h:outputText value="#{item.vin}" />
      </rich:column>
      <rich:column>
         <h:outputText value="#{item.stock}" />
      </rich:column>
      <rich:column>
         <h:outputText value="#{item.daysLive}" />
      </rich:column>
      <f:facet name="footer">
         <h:outputText value="Total of #{list.vendor} Cars: #{list.count}" />
      </f:facet>
   </rich:collapsibleSubTable>
</rich:dataTable>

The resulting tables contains multiple sub-tables, grouping the list of cars by vendor. Each sub-table can be expanded or collapsed using the toggle with the vendor's name. The screenshot shows all sub-tables collapsed except for the sub-table for Ford cars.


Table 9.2. Style classes (selectors) and corresponding skin parameters

Class (selector)Skin ParametersMapped CSS properties
.rf-cst

This class defines styles for the table.

No skin parameters.
.rf-cst-r

This class defines styles for a table row.

No skin parameters.
.rf-cst-fst-r

This class defines styles for the first row in a table.

No skin parameters.
.rf-cst-c

This class defines styles for a table cell.

tableBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-cst-hdr

This class defines styles for a table header.

No skin parameters.
.rf-cst-hdr-fst

This class defines styles for the first header.

No skin parameters.
.rf-cst-hdr-fst-r

This class defines styles for the first row in the header.

No skin parameters.
.rf-cst-hdr-c

This class defines styles for a header cell.

tableSubHeaderBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-cst-shdr

This class defines styles for a table sub-header.

No skin parameters.
.rf-cst-shdr-fst

This class defines styles for the first sub-header.

No skin parameters.
.rf-cst-shdr-c

This class defines styles for a sub-header cell.

tableSubHeaderBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-cst-ftr

This class defines styles for a table footer.

No skin parameters.
.rf-cst-ftr-fst

This class defines styles for the first footer.

No skin parameters.
.rf-cst-ftr-c

This class defines styles for a footer cell.

tableSubFooterBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-cst-sftr

This class defines styles for a table sub-footer.

No skin parameters.
.rf-cst-sftr-fst

This class defines styles for the first sub-footer.

No skin parameters.
.rf-cst-sftr-c

This class defines styles for a sub-footer cell.

tableSubFooterBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size


The <rich:extendedDataTable> component builds on the functionality of the <rich:dataTable> component, adding features such as data scrolling, row and column selection, and rearranging of columns.

The <rich:extendedDataTable> component includes the following main attributes not included in the <rich:dataTable> component:

The <rich:extendedDataTable> component does not include the following attributes available with the <rich:dataTable> component:

Example 9.8. <rich:extendedDataTable> example

This example <rich:extendedDataTable> component demonstrates horizontal and vertical scrolling and frozen columns. Each feature is detailed in this section.


<rich:extendedDataTable value="#{carsBean.allInventoryItems}"
                        var="car" id="table" frozenColumns="2"
                        style="height:300px; width:500px;" selectionMode="none">
   <f:facet name="header">
      <h:outputText value="Cars marketplace" />
   </f:facet>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="vendor" />
      </f:facet>
      <h:outputText value="#{car.vendor}" />
   </rich:column>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="Model" />
      </f:facet>
      <h:outputText value="#{car.model}" />
   </rich:column>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="Price" />
      </f:facet>
      <h:outputText value="#{car.price}" />
   </rich:column>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="Mileage" />
      </f:facet>
      <h:outputText value="#{car.mileage}" />
   </rich:column>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="VIN Code" />
      </f:facet>
      <h:outputText value="#{car.vin}" />
   </rich:column>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="Items stock" />
      </f:facet>
      <h:outputText value="#{car.stock}" />
   </rich:column>
   <rich:column>
      <f:facet name="header">
         <h:outputText value="Days Live" />
      </f:facet>
      <h:outputText value="#{car.daysLive}" />
   </rich:column>
</rich:extendedDataTable>

The example table shown in Example 9.8, “<rich:extendedDataTable> example” features both horizontal and vertical scrolling. Scrolling occurs automatically when the contents of the table exceed the dimensions specified with the height and width attributes. Headers and footers remain in place and visible when the table is scrolled.

Large tables can use Ajax "lazy" loading to cache data on the client during scrolling. Use the clientRows attribute to specify the number of rows to load. The specified number of rows are loaded on the initial rendering and with every vertical scroll. If the clientRows attribute is not specified, all the rows are loaded on the client without the use of Ajax.

In addition to Ajax scrolling, the <rich:extendedDataTable> component can also be used with the <rich:dataScroller> component in the same way as a regular <rich:dataTable> component. Refer to Section 9.9, “<rich:dataScroller>” for full details on using the <rich:dataScroller> component.

The example table shown in Example 9.8, “<rich:extendedDataTable> example” has the first two columns frozen so that they remain visible if the user scrolls horizontally through the table. Note that the horizontal scrollbar does not encompass these frozen columns. To freeze columns, use the frozenColumns attribute to specify the number of columns on the left-hand side of the table to freeze.

Row selection is determined by the selectionMode attribute. Setting the attribute to none allows for no row selection capability. The example table shown in Example 9.8, “<rich:extendedDataTable> example” does not allow row selection.

Setting the selectionMode attribute to single allows the user to select a single row at a time using the mouse. With the selectionMode attribute set to multiple, the user can select multiple rows. Holding down the Ctrl key while clicking selects additional rows with each click. Holding down the Shift key while clicking selects all the rows in a range.

The selection attribute points to a collection of objects. It holds the rowKey identifiers to track which rows are selected. Example 9.9, “Selecting multiple rows” shows how to implement multiple row selection in the same table from Example 9.8, “<rich:extendedDataTable> example”.

Example 9.9. Selecting multiple rows


<rich:extendedDataTable value="#{extTableSelectionBean.inventoryItems}" 
                        var="car" selection="#{extTableSelectionBean.selection}"
                        id="table" frozenColumns="2" 
                        style="height:300px; width:500px;" selectionMode="multiple">
   ...

The accompanying ExtSelectionBean bean handles which rows are selected. The rows are identified by their rowKey identifiers.

package org.richfaces.demo.tables;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.event.AjaxBehaviorEvent;
import org.richfaces.component.UIExtendedDataTable;
import org.richfaces.demo.tables.model.cars.InventoryItem;
@ManagedBean
@SessionScoped
public class ExtTableSelectionBean implements Serializable{
   private Collection<Object> selection;
   @ManagedProperty(value = "#{carsBean.allInventoryItems}")
   private List<InventoryItem> inventoryItems;
   private List<InventoryItem> selectionItems = new ArrayList<InventoryItem>();
   public void selectionListener(AjaxBehaviorEvent event){
      UIExtendedDataTable dataTable = (UIExtendedDataTable)event.getComponent();
      Object originalKey = dataTable.getRowKey();
      selectionItems.clear();
      for (Object selectionKey: selection) {
         dataTable.setRowKey(selectionKey);
         if (dataTable.isRowAvailable()){
            selectionItems.add((InventoryItem)dataTable.getRowData());
         }
      }
      dataTable.setRowKey(originalKey);
   }
   public Collection<Object> getSelection() {
      return selection;
   }
   public void setSelection(Collection<Object> selection) {
      this.selection = selection;
   }
   public List<InventoryItem> getInventoryItems() {
      return inventoryItems;
   }
   public void setInventoryItems(List<InventoryItem> inventoryItems) {
      this.inventoryItems = inventoryItems;
   }
   public List<InventoryItem> getSelectionItems() {
      return selectionItems;
   }
   public void setSelectionItems(List<InventoryItem> selectionItems) {
      this.selectionItems = selectionItems;
   }
}

Columns in a <rich:extendedDataTable> component can be rearranged by the user by dragging each column to a different position. A graphical representation of the column is displayed during dragging. Figure 9.6, “Dragging columns” illustrates the Price column being dragged to a new location. The small blue arrow indicates where the column will be moved to if it is dropped in the current position. Figure 9.7, “Rearranged columns” shows the result of dragging the Price column.

Figure 9.6. Dragging columns


Figure 9.7. Rearranged columns


Table 9.3. Style classes (selectors) and corresponding skin parameters

Class (selector)Skin ParametersMapped CSS properties
.rf-edt

This class defines styles for the table.

tableBorderWidth, tableBorderColor

border

tableBackgroundColor

background-color

.rich-edt-cnt

This class defines styles for the table content.

No skin parameters.
.rf-edt-c

This class defines styles for a table cell.

tableBorderWidth, tableBorderColor

border-bottom

tableBorderWidth, tableBorderColor

border-right

.rf-edt-c-cnt

This class defines styles for the contents of a cell.

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-edt-tbl-hdr

This class defines styles for the table header.

tableBorderWidth, tableBorderColor

border-bottom

tableHeaderTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

tableHeaderTextColor

color

.rich-edt-hdr

This class defines styles for a header.

No skin parameters.
.rf-edt-hdr-c

This class defines styles for a table header cell.

tableBorderWidth, tableBorderColor

border-bottom

tableBorderWidth, tableBorderColor

border-right

.rf-edt-hdr-c-cnt

This class defines styles for the contents of a header cell.

generalFamilyFont

font-family

generalSizeFont

font-size

tableHeaderTextColor

color

.rf-edt-tbl-ftr

This class defines styles for the table footer.

tableBorderWidth, tableBorderColor

border-top

tableFooterBackgroundColor

background-color

.rich-edt-ftr

This class defines styles for a footer.

tableBorderWidth, tableBorderColor

border-top

tableFooterBackgroundColor

background-color

.rich-edt-ftr-cnt

This class defines styles for the content of a footer.

No skin parameters.
.rf-edt-ftr-c

This class defines styles for a table footer cell.

tableBorderWidth, tableBorderColor

border-bottom

tableBorderWidth, tableBorderColor

border-right

.rf-edt-ftr-c-cnt

This class defines styles for the contents of a footer cell.

generalFamilyFont

font-family

generalSizeFont

font-size

generalTextColor

color

.rf-edt-ftr-emp

This class defines styles for an empty footer cell.

tableBorderWidth, tableBorderColor

border-right

.rich-edt-ftr-fzn

This class defines styles for a frozen footer.

No skin parameters.
.rich-edt-b

This class defines styles for the body of the table.

No skin parameters.
.rf-edt-r-sel

This class defines styles for the selected row.

tableBorderWidth, tableBorderColor

border-right

.rich-edt-r-act

This class defines styles for the active row.

No skin parameters.
.rich-edt-rsz

This class defines styles for the table resizer.

No skin parameters.
.rich-edt-rsz-cntr

This class defines styles for the resize container.

No skin parameters.
.rich-edt-rsz-mkr

This class defines styles for the resize marker.

generalTextColor

border-left

.rf-edt-rord

This class defines styles for the re-order functionality.

tableBorderWidth, tableBorderColor

border

tableHeaderBackgroundColor / tableBackgroundColor

background-color

.rich-edt-rord-mkr

This class defines styles for the re-order marker.

No skin parameters.
.rich-edt-spcr

This class defines a spacer for Internet Explorer 7 compatibility.

No skin parameters.

The <rich:dataGrid> component is used to arrange data objects in a grid. Values in the grid can be updated dynamically from the data model, and Ajax updates can be limited to specific rows. The component supports header, footer, and caption facets.

The <rich:dataGrid> component is similar in function to the JavaServer Faces <h:panelGrid> component. However, the <rich:dataGrid> component additionally allows iteration through the data model rather than just aligning child components in a grid layout.

Figure 9.8. The <rich:dataGrid> component


Table 9.4. Style classes (selectors) and corresponding skin parameters

Class (selector)Skin ParametersMapped CSS properties
.rf-dg

This class defines styles for the grid.

tableBackgroundColor

background-color

tableBorderWidth

border-left-width, border-top-width

tableBorderColor

border-left-color, border-top-color

.rf-dg-cap

This class defines styles for the grid caption.

No skin parameters.
.rf-dg-r

This class defines styles for a grid row.

No skin parameters.
.rf-dg-c

This class defines styles for a grid cell.

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dg-nd-c

This class defines styles for a node cell.

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dg-th

This class defines styles for the grid header section.

tableBorderWidth

border-bottom-width

tableBorderColor

border-bottom-color

.rf-dg-h

This class defines styles for a grid header.

No skin parameters.
.rf-dg-h-f

This class defines styles for the first header.

No skin parameters.
.rf-dg-h-r

This class defines styles for a header row.

No skin parameters.
.rf-dg-h-c

This class defines styles for a header cell.

tableHeaderBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

tableHeaderTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

.rf-dg-f

This class defines styles for a grid footer.

No skin parameters.
.rf-dg-f-f

This class defines styles for the first footer.

No skin parameters.
.rf-dg-f-c

This class defines styles for a footer cell.

tableFooterBackgroundColor

background-color

tableBorderWidth

border-bottom-width, border-right-width

tableBorderColor

border-bottom-color, border-right-color

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size


The <rich:list> component renders a list of items. The list can be an numerically ordered list, an un-ordered bullet-point list, or a data definition list. The component uses a data model for managing the list items, which can be updated dynamically.

The <rich:dataScroller> component is used for navigating through multiple pages of tables or grids.

Figure 9.14. The <rich:dataScroller> component


The page attribute is a value-binding attribute used to define and save the current page number.

The <rich:dataScroller> component provides a range of controllers for scrolling through tables and grids:

The pageIndexVar and pagesVar attributes are request-scope variables for the current page and the total number of pages. Use these attributes with the pages facet to provide information about the pages of the table, as shown in Example 9.14, “pages facet”.


To add optional separators between controls, define the separators with the controlsSeparator facet.

Table 9.6. Style classes (selectors) and corresponding skin parameters

Class (selector)Skin ParametersMapped CSS properties
.rf-ds

This class defines styles for the data scroller.

generalFamilyFont

font-family

generalSizeFont

font-size

tableBackgroundColor

background

.rf-ds-btn

This class defines styles for buttons in the data scroller.

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

tableBorderColor

border-color

headerBackgroundColor

background-color

.rf-ds-btn-first

This class defines styles for the first button.

No skin parameters.
.rf-ds-btn-fastrwd

This class defines styles for the fast rewind button.

No skin parameters.
.rf-ds-btn-prev

This class defines styles for the previous button.

No skin parameters.
.rf-ds-btn-next

This class defines styles for the next button.

No skin parameters.
.rf-ds-btn-fastfwd

This class defines styles for the fast forward button.

No skin parameters.
.rf-ds-btn-last

This class defines styles for the last button.

No skin parameters.
.rf-ds-nmb-btn

This class defines styles for page number buttons in the data scroller.

generalTextColor

color

generalFamilyFont

font-family

generalSizeFont

font-size

tableBorderColor

border-color

tableBackgroundColor

background-color

.rf-ds-press

This class defines styles for a data scroller when a control is pressed.

tableBorderColor

border-color

tableBackgroundColor

background

 
.rf-ds-act

This class defines styles for an active data scroller.

tableBorderColor

color

.rf-ds-dis

This class defines styles for a disabled data scroller.

tableBorderColor

color


Tables entries can be filtered by the user through either the basic method built in to the <rich:column> component, or by defining external filters. Refer to Section 9.3, “<rich:column>” for details on using the <rich:column> component in tables.

The built-in filtering abilities of the <rich:column> component allow the user to enter text as a filtering value. The table displays only those entries that begin with the filter value.

Set the filterValue attribute to point to the value used to filter the column. This can be either an initial filtering value on the page, or a value binding on the server. The filterValue value is then used with the JavaScript startsWith() method to filter the column entries based on the data specified with the filterBy attribute. Expressions in the filterBy attribute must refer to the variable declared in the table's var attribute, which is used to fill the contents of the table.

The filter is processed and the table is rendered when the onblur event occurs for the column. This can be changed by defining a different event with the filterEvent attribute. For example, to implement live updating such that the filter refreshes after every keystroke, set filterEvent="keyup".


If you require more advanced filtering using custom functions or expressions, use the external filtering properties of the <rich:column> component.

Use the filterExpression attribute to define an expression that can be evaluated as a boolean value. The expression checks if each table entry satisfies the filtering condition when the table is rendered.

Use the filterMethod attribute to define a method binding. The method needs to accept an object as a parameter and return a boolean value. Similar to the filterExpression attribute, the table is rendered only with those entries that satisfy the filtering condition. By defining a custom filtering method, you can implement complex business logic to filter a table.

Example 9.16. External filtering


<rich:dataTable value="#{capitalsBean.capitals}" var="cap" id="table">
   <f:facet name="header">
      <rich:column>
         <h:outputText value="State Name">
      </rich:column>
      <rich:column>
         <h:outputText value="State Time Zone">
      </rich:column>
   </f:facet>
   <rich:column filterMethod="#{filteringBean.filterStates}">
        <f:facet name="header">
            <h:inputText value="#{filteringBean.filterValue}" id="input">
                <a4j:ajax event="keyup" render="table"
                              ignoreDupResponses="true" requestDelay="700"/>
            </h:inputText>
        </f:facet>
      <h:outputText value="#{cap.state}"/>
   </rich:column> 
   <rich:column filterExpression=
      "#{fn:containsIgnoreCase(cap.timeZone, filteringBean.filterZone)}">
        <f:facet name="header">
            <h:selectOneMenu value="#{filteringBean.filterZone}">
                <f:selectItems value="#{filteringBean.filterZones}" />
                <a4j:ajax event="change" render="table" />
            </h:selectOneMenu>
        </f:facet>
      <h:outputText value="#{cap.timeZone}"/> 
   </rich:column>
</rich:dataTable>

The example uses a filter expression on the first column and a filter method on the second column.


Tables entries can be sorted by defining external sorting algorithms. Refer to Section 9.3, “<rich:column>” for details on using the <rich:column> component in tables.

Sorting non-English tables

To sort a table whose contents are not in English, add the org.richfaces.datatableUsesViewLocale context parameter to the project's web.xml settings file. Set the value of the context parameter to true.

Bind the sortOrder attribute to bean properties to manage the sorting order externally. The bean must handle all the sorting algorithms. Example 9.17, “External sorting” demonstrates table sorting using an external control.

Example 9.17. External sorting


<rich:dataTable value="#{dataTableScrollerBean.allCars}"
                var="category" rows="20" id="table" reRender="ds2"
                sortPriority="#{sortingBean.prioritList}">
   <rich:column id="make" sortBy="#{category.make}"
                sortOrder="#{sortingBean.makeDirection}">
      <f:facet name="header">
         <h:outputText styleClass="headerText" value="Make" />
      </f:facet>
      <h:outputText value="#{category.make}" />
   </rich:column>
   <rich:column id="model" sortBy="#{category.model}"
                sortOrder="#{sortingBean.modelDirection}">
      <f:facet name="header">
         <h:outputText styleClass="headerText" value="Model" />
      </f:facet>
      <h:outputText value="#{category.model}" />
   </rich:column>
   <rich:column id="price" sortBy="#{category.price}"
                sortOrder="#{sortingBean.priceDirection}">
      <f:facet name="header">
         <h:outputText styleClass="headerText" value="Price" />
      </f:facet>
      <h:outputText value="#{category.price}" />
   </rich:column>
   <rich:column id="mileage" sortBy="#{category.mileage}"
                sortOrder="#{sortingBean.mileageDirection}">
      <f:facet name="header">
         <h:outputText styleClass="headerText" value="Mileage" />
      </f:facet>
      <h:outputText value="#{category.mileage}" />
   </rich:column>
</rich:dataTable>

The example uses an external control to manage the table's sorting.


When using the sortMode="multiple" configuration, set the priority by which columns are sorted with the sortPriorities attribute.

Use the sortExpression attribute to define a bean property to use for sorting the column. The expression checks each table entry against the sorting expression during rendering.