Send your remarks, comments or wishes to doc team
Subject:
Message:
Your name:
Your email:

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

    ...

        <a4j:poll intervall="1000" action="#{repeater.action}" reRender="text">

            <table>

                <tbody>

                    <a4j:repeat value="#{bean.props}" var="detail" ajaxKeys="#{repeater.ajaxedRowsSet}">

                        <tr>

                            <td>

                                <h:outputText value="detail.someProperty" id="text"/>

                            </td>

                        </tr>

                    </a4j:repeat>

                </tbody>

            </table>

        </a4j:poll>

    ...

Thus, a list with a table structure from `bean.props` is output.

In the above-mentioned example the component <a4j:poll> sends Ajax requests every second, calling the `action` method of the `repeater` bean.

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

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