Using apex:repeat in Visualforce Page

apex:repeat is an iteration component that allows us to output the contents of a collection according to a structure that you specify. The collection can include up to 1,000 items.

Note: If apex:repeat is 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.

apex:repeat can’t be used as a direct child of the following components:

  • < apex:dataTable >
  • < apex:pageBlockTable >
  • <apex:panelBar>
  • <apex:selectCheckboxes>
  • <apex:selectList>
  • <apex:selectRadio>

Visualforce Page:
apexRepeatPage

<apex:page controller="apexRepeatClass" id="pageId">
    <apex:repeat value="{!weekdays}" var="weekday" id="repeatBlockId">
        <apex:outputText value="{!weekday}" id="theValue"/><br/>
    </apex:repeat>
</apex:page>

Apex Code:
apexRepeatClass

public String[] getWeekdays() {
    return new String[]{'MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY'};
        }

Output: