### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

## 6.22. < a4j:repeat >

### 6.22.1. Description

The <a4j:repeat> component implements a basic iteration component allowing to update a set of its children with AJAX.

Table 6.45. a4j : repeat attributes

Attribute Name | Description
--- | ---
ajaxKeys | This attribute defines row keys that are updated after an AJAX request.
binding | The attribute takes a value-binding expression for a component property of a backing bean
componentState | It defines EL-binding for a component state for saving or redefinition.
first | A zero-relative row number of the first row to display
id | Every component may have a unique id that is automatically created if omitted
rendered | If "false", this component is not rendered
rowKeyConverter | Converter for a row key object
rowKeyVar | The attribute provides access to a row key in a Request scope.
rows | A number of rows to display, or zero for all remaining rows in the table
stateVar | The attribute provides access to a component state on the client side.
value | The current value for this component.
var | A request-scope attribute via which the data object for the current row will be used when iterating

Table 6.46. Component identification parameters

Name | Value
--- | ---
component-type | org.ajax4jsf.Repeat
component-family | javax.faces.Data
component-class | org.ajax4jsf.component.html.HtmlAjaxRepeat
renderer-type | org.ajax4jsf.components.RepeatRenderer

### 6.22.2. Creating on a page

The component definition on a page is the same as for the facelets component:

    <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.

### 6.22.3. Creating the Component Dynamically Using Java

Example:

    import org.ajax4jsf.component.html.HtmlAjaxRepeat;

    ...

    HtmlAjaxRepeat repeater = new HtmlAjaxRepeat ();

    ...

### 6.22.4. Key attributes and ways of usage

The main difference of this component from iterative components of other libraries is a special "ajaxKeys" attribute. This attribute defines row keys 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>

    ...

## Note:

The <a4j:repeat> component is defined as fully updated, but really updated there are only the row keys which defined in the "ajaxKeys" attribute.

The set could be defined during the action method processing using data on a model from the property `repeater.myRepeat`

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.

### 6.22.5. Relevant resources links

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

- Prev6.21. < a4j:region >
- Top of page
- Front page
- Next6.23. < a4j:status >