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.11.  < rich:subTable > available since 3.0.0

The component is used for inserting subtables into tables with opportunity to choose data from a model and built-in Ajax updates support.


Table 6.100. rich : subTable attributes

Attribute Name Description
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
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.
componentStateIt defines EL-binding for a component state for saving or redefinition
firstA zero-relative row number of the first row to display
footerClassAssigns one or more space-separated CSS class names to any footer generated for this component
headerClassAssigns one or more space-separated CSS class names to any header generated for this component
id JSF: Every component may have a unique id that is automatically created if omitted
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
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
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 row key 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
stateVarThe attribute provides access to a component state on the client side
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

Table 6.101. Component identification parameters

NameValue
component-typeorg.richfaces.SubTable
component-classorg.richfaces.component.html.HtmlSubTable
component-familyorg.richfaces.SubTable
renderer-typeorg.richfaces.SubTableRenderer
tag-classorg.richfaces.taglib.SubTableTag

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:subTable value=#{capitals.detailsvar="detail">
                <rich:column>
                    ...
                </rich:column>
        </rich:subTable>
</rich:dataTable>
...

Example:

import org.richfaces.component.html.HtmlSubTable;

...
HtmlSubTable mySubTable = new HtmlSubTable();
...

The <rich:subTable> component is similar to the <h:dataTable> one, except Ajax support and skinnability. One more difference is that the component doesn't add the wrapping <table> and <tbody> tags. 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">
        <rich:column>
                ...
        </rich:column>
        <rich:subTable value="#{capitals.details}" var="detail" ajaxKeys="#{bean.ajaxSet}" binding="#{bean.subtable}" id="subtable">
                <rich:column>
                    ...
                </rich:column>
        </rich:subTable>
</rich:dataTable>
...
<a4j:commandButton action="#{tableBean.action}" reRender="subtable"/>
...

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

The component allows to use "header" and "footer" facets for output. See an example for <rich:dataTable> component.


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:subTable> components at once:

Skin parameters redefinition for <rich:subTable> are the same as for the <rich:dataTable> component.





In order to redefine styles for all <rich:subTable> 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-subtable-footer{
        
font-weight: bold;
} 
...

This is a result:


In the example a footer font weight was changed.

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

Example:


...
.myClass{
  
background-color: #fff5ec;
}
...

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

Example:


<rich:subTable ... columnClasses="myClass"/>

This is a result:


As it could be seen on the picture above, the background color for columns was changed.