Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.6.10.  < rich:dataTable > available since 3.0.0

The component for tables rendering that allows choosing data from a model and obtains built-in support of Ajax updates.


Table 6.88. rich : dataTable attributes

Attribute Name Description
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
alignDeprecated. This attribute specifies the position of the table with respect to the document. The possible values are "left", "center" and "right". The default value is "left".
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
borderHTML: This attributes specifies the width of the frame around a component. Default value is "0".
captionClassAssigns one or more space-separated CSS class names to the component caption
captionStyleCSS style rules to be applied to the component caption
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents. Default value is "0".
cellspacingThis attribute specifies the amount of space between the border of the cell and its contents. The attribute also specifies the amount of space to leave between cells. Default value is "0".
columnClasses JSF: Assigns one or more space-separated CSS class names to the columns of the table. If the CSS class names are comma-separated, each class will be assigned to a particular column in the order they follow in the attribute. If you have less class names than columns, the class will be applied to every n-fold column where n is the order in which the class is listed in the attribute. If there are more class names than columns, the overflow ones are ignored.
columnsSpecifies the number of columns
columnsWidthComma-separated list of width attribute for every column. Specifies a default width for each column in the table. In addition to the standard pixel, percentage, and relative values, this attribute allows the special form "0*" (zero asterisk) which means that the width of the each column in the group should be the minimum width necessary to hold the column's contents. This implies that a column's entire contents must be known before its width may be correctly computed. Authors should be aware that specifying "0*" will prevent visual user agents from rendering a table incrementally
componentStateIt defines EL-binding for a component state for saving or redefinition
dirHTML: Direction indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
footerClassAssigns one or more space-separated CSS class names to the component footer
frameThis attribute specifies which sides of the frame surrounding a table will be visible. Possible values: "void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box" and "border". The default value is "void".
headerClassAssigns one or more space-separated CSS class names to the component header
id JSF: Every component may have a unique id that is automatically created if omitted
langHTML: Code describing the language used in the generated markup for this component
onclick DHTML: The client-side script method to be called when the element is clicked
ondblclick DHTML: The client-side script method to be called when the element is double-clicked
onkeydown DHTML: The client-side script method to be called when a key is pressed down over the element
onkeypress DHTML: The client-side script method to be called when a key is pressed over the element and released
onkeyup DHTML: The client-side script method to be called when a key is released
onmousedown DHTML: The client-side script method to be called when a mouse button is pressed down over the element
onmousemove DHTML: The client-side script method to be called when a pointer is moved within the element
onmouseout DHTML: The client-side script method to be called when a pointer is moved away from the element
onmouseover DHTML: The client-side script method to be called when a pointer is moved onto the element
onmouseup DHTML: The client-side script method to be called when a mouse button is released
onRowClickThe client-side script method to be called when the row is clicked
onRowContextMenuThe client-side script method to be called when a right mouse button is clicked over the row. Returning false prevents default browser context menu from being displayed.
onRowDblClickThe client-side script method to be called when the row is double-clicked
onRowMouseDownThe client-side script method to be called when a mouse button is pressed down over the row
onRowMouseMoveThe client-side script method to be called when a pointer is moved within the row
onRowMouseOutThe client-side script method to be called when a pointer is moved away from the row
onRowMouseOverThe client-side script method to be called when a pointer is moved onto the row
onRowMouseUpThe client-side script method to be called when a mouse button is released over the row
rendered JSF: If "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClasses JSF: Assigns one or more space-separated CSS class names to the rows of the table. If the CSS class names are comma-separated, each class will be assigned to a particular row in the order they follow in the attribute. If you have less class names than rows, the class will be applied to every n-fold row where n is the order in which the class is listed in the attribute. If there are more class names than rows, the overflow ones are ignored.
rowKeyConverterConverter for a RowKey object.
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsHTML: A number of rows to display, or zero for all remaining rows in the table
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
sortModeDefines mode of sorting. Possible values are 'single' for sorting of one column and 'multi' for some.
sortPriorityDefines a set of columns ids in the sorting order
stateVarThe attribute provides access to a component state on the client side
styleHTML: CSS style rules to be applied to the component
styleClass JSF: Assigns one or more CSS class names to the component. Corresponds to the HTML "class" attribute.
titleHTML: Advisory title information about markup elements generated for this component
value JSF: The current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthHTML: This attribute specifies the desired width of the entire table and is intended for visual user agents. When the value is percentage value, the value is relative to the user agent's available horizontal space. In the absence of any width specification, table width is determined by the user agent

Table 6.89. Component identification parameters

NameValue
component-typeorg.richfaces.DataTable
component-classorg.richfaces.component.html.HtmlDataTable
component-familyorg.richfaces.DataTable
renderer-typeorg.richfaces.DataTableRenderer
tag-classorg.richfaces.taglib.DataTableTag

Here is a simple example as it could be used on a page:

Example:


...
 <rich:dataTable value="#{capitalsBean.capitals}" var="capitals">
        <rich:column>
                ...
        </rich:column>
</rich:dataTable>
...

Example:

import org.richfaces.component.html.HtmlDataTable;

...
HtmlDataTable myTable = new HtmlDataTable();
...

The <rich:dataTable> component is similar to the <h:dataTable> one, except Ajax support and skinnability. Ajax support is possible, because the component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. "ajaxKeys" attribute allows to define row keys that is updated after an Ajax request.

Here is an example:

Example:


...
<rich:dataTable value="#{capitalsBean.capitals}" var="capitals"
                ajaxKeys="#{bean.ajaxSet}" binding="#{bean.table}" id="table">
        ...
</rich:dataTable>
...
<a4j:commandButton action="#{tableBean.action}" reRender="table" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataTable> component. As a result the component is updated after an Ajax request.

The component allows to use "header" , "footer" and "caption" facets for output. See an example below:

Example:


...
<rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
        <f:facet name="caption">
                <h:outputText value="United States Capitals" />
        </f:facet>
        <f:facet name="header">
                <h:outputText value="Capitals and States Table" />
        </f:facet>
        <rich:column>
                <f:facet name="header">State Flag</f:facet>
                        <h:graphicImage value="#{cap.stateFlag}"/>
                <f:facet name="footer">State Flag</f:facet>
        </rich:column>
        <rich:column>
                <f:facet name="header">State Name</f:facet>
                        <h:outputText value="#{cap.state}"/>
                <f:facet name="footer">State Name</f:facet>
        </rich:column>
        <rich:column >
                <f:facet name="header">State Capital</f:facet>
                        <h:outputText value="#{cap.name}"/>
                <f:facet name="footer">State Capital</f:facet>
        </rich:column>
        <rich:column>
                <f:facet name="header">Time Zone</f:facet>
                    <h:outputText value="#{cap.timeZone}"/>
                <f:facet name="footer">Time Zone</f:facet>
        </rich:column>
        <f:facet name="footer">
                <h:outputText value="Capitals and States Table" />
        </f:facet>
</rich:dataTable>
...

This is a result:


Information about sorting and filtering you can find in the corresponding section.

You can find information how to remove header's gradient in the "How to remove rich:dataTable header background " article.


For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all <rich:dataTable> components at once:







On the screenshot there are classes names that define styles for component elements.





In order to redefine styles for all <rich:dataTable> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-table-cell{
    
font-weight:bold;
}
...

This is a result:


In the example the font weight for table cell was changed.

Also it's possible to change styles of particular <rich:dataTable> component. In this case you should create own style classes and use them in corresponding <rich:dataTable> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-style:italic;
}
...

The "headerClass" attribute for <rich:dataTable> is defined as it's shown in the example below:

Example:


<rich:dataTable  ... headerClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style for header was changed.

Detailed information on how to set <rich:dataTable> border to "0px" you can find in the " How to set rich:dataTable border to 0px article " .

On the component LiveDemo page you can see the example of <rich:dataTable> usage and sources for the given example.

The article about <rich:dataTable> flexibility can be found in the "rich:dataTable Flexibility " article .

Article on dataTable skinability provides you a simple example of skinnability.

More information about using <rich:dataTable> and <rich:subTable> could be found on the RichFaces Users Forum.

How to use <rich:dataTable> and <rich:datascroller> in a context of Extended Data Model see on the RichFaces Users Forum.

From "rich:dataTable border to 0px " article you'll figure out how to set rich:dataTable border to 0px

dataTable Background Out tells you how to remove rich:dataTable header background