apex:repeat

An iteration component that allows you to output the contents of a collection according to a structure that you specify. The collection can include up to 1,000 items.

Note that if used within an <apex:pageBlockSection> or <apex:panelGrid> component, all content generated by a child <apex:repeat> component is placed in a single <apex:pageBlockSection> or <apex:panelGrid> cell.

This component can't be used as a direct child of the following components:

Example

<!-- Page: -->

<apex:page controller="repeatCon" id="thePage">

    <apex:repeat value="{!strings}" var="string" id="theRepeat">

        <apex:outputText value="{!string}" id="theValue"/><br/>

    </apex:repeat>

</apex:page>


/*** Controller: ***/

public class repeatCon {

    public String[] getStrings() {
        return new String[]{'ONE','TWO','THREE'};
    }

}

The example above renders the following HTML:

<span id="thePage:theRepeat:0:theValue">ONE</span><br/>

<span id="thePage:theRepeat:1:theValue">TWO</span><br/>

<span id="thePage:theRepeat:2:theValue">THREE</span><br/>

Standard Component Example

<!-- For this example to render properly, you must associate the Visualforce page 

with a valid account record in the URL. 

For example, if 001D000000IRt53 is the account ID, the resulting URL should be: 

https://Salesforce_instance/apex/myPage?id=001D000000IRt53

See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->

         



<!-- Page: -->

<apex:page standardController="Account">

    <table border="0" >

        <tr>

            <th>Case Number</th><th>Origin</th>

            <th>Creator Email</th><th>Status</th>

        </tr>

        <apex:repeat var="cases" value="{!Account.Cases}">

        <tr>

            <td>{!cases.CaseNumber}</td>

            <td>{!cases.Origin}</td>

            <td>{!cases.Contact.email}</td>

            <td>{!cases.Status}</td>

        </tr>

        </apex:repeat> 

    </table>

</apex:page>

Attributes

Attribute Name Attribute Type Description Required? API Version Access
first Integer The first element in the collection visibly rendered, where 0 is the index of the first element in the set of data specified by the value attribute. For example, if you did not want to display the first two elements in the set of records specified by the value attribute, set first="2". 10.0 global
id String An identifier that allows the repeat component to be referenced by other components in the page. 10.0 global
rendered Boolean A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true. 10.0 global
rows Integer The maximum number of items in the collection that are rendered. If this value is less than the number of items in the collection, the items at the end of the collection are not repeated. 10.0 global
value Object The collection of data that is iterated over. 10.0 global
var String The name of the variable that represents the current item in the iteration. 10.0 global