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.13.  < a4j:repeat > available since 3.0.0

The <a4j:repeat> component implements a basic iteration component that allows to update a set of its children with Ajax.

Table 6.118. a4j : repeat 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
componentStateIt defines EL-binding for a component state for saving or redefinition.
firstA zero-relative row number of the first row to display
id JSF: Every component may have a unique id that is automatically created if omitted
rendered JSF: If "false", this component is not rendered
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.119. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Repeat
component-familyjavax.faces.Data
component-classorg.ajax4jsf.component.html.HtmlAjaxRepeat
renderer-typeorg.ajax4jsf.components.RepeatRenderer


To create the simplest variant on a page use the following syntax:


<a4j:repeat id="detail" value="#{bean.props}" var="detail">
    <h:outputText value="#{detail.someProperty}"/>
</a4j:repeat>

The output is generated according to a collection contained in bean.props with the detail key passed to child components.

Example:

import org.ajax4jsf.component.html.HtmlAjaxRepeat;

...
HtmlAjaxRepeat repeater = new HtmlAjaxRepeat ();
...

The <a4j:repeat> component is similar to Facelets <ui:repeat> tag, which is used to iterate through a collection of objects binded with JSF page as EL expression. The main difference of the <a4j:repeat> is a possibility to update particular components (it's children) instead of all using Ajax requests. The feature that makes the component different is a special "ajaxKeys" attribute that defines row that are updated after an Ajax request. As a result it becomes easier to update several child components separately without updating the whole page.


...
<table>
      <tbody>
            <a4j:repeat value="#{repeatBean.items}" var="item" ajaxKeys="#{updateBean.updatedRow}">
                  <tr>
                        <td><h:outputText value="#{item.code}" id="item1" /></td>
                        <td><h:outputText value="#{item.price}" id="item2" /></td>
                  </tr>
            </a4j:repeat>
      </tbody>
</table>
 ...

The example above the <a4j:repeat> points to an method that contains row keys to be updated.

One more benefit of this component is absence of strictly defined markup as JSF HTML DataTable and TOMAHAWK DataTable has. Hence the components could be used more flexibly anywhere where it's necessary to output the results of selection from some collection.

The next example shows collection output as a plain HTML list:


<ul>
      <a4j:repeat ...>
        <li>...<li/>
                   ...
        <li>...<li/>
      </a4j:repeat>
</ul>

All other general attributes are defined according to the similar attributes of iterative components ( <h:dataTable> or <ui:repeat> ) and are used in the same way.

Vizit the Repeat page at RichFaces LiveDemo for examples of component usage and their sources.