The a4j:repeat component is the basic iteration component of RichFaces. It allows the creation of any markup based on iterative data. This example shows a simple grid produced from a list of capital cities.
<!DOCTYPE html> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <style type="text/css"> .panel { float:left; width:190px; padding:5px; } .panel .rf-p-b { font-size: 12px; } </style> <h:form id="form"> <h:panelGrid columns="1" style="width: 640px"> <a4j:outputPanel id="panel" layout="block"> <a4j:repeat value="#{capitalsBean.capitals}" var="cap" rows="15" id="repeat"> <rich:panel styleClass="panel"> <f:facet name="header"> <h:panelGroup> <h:graphicImage value="#{cap.stateFlag}" alt="flag" /> <h:outputText value="#{cap.state}" style="font-weight:bold; margin-left: 4px" /> </h:panelGroup> </f:facet> <h:panelGrid columns="2"> <h:outputText value="State Capital" style="font-weight:bold" /> <h:outputText value="#{cap.name}" /> <h:outputText value="State TimeZone" style="font-weight:bold" /> <h:outputText value="#{cap.timeZone}" /> </h:panelGrid> </rich:panel> </a4j:repeat> </a4j:outputPanel> <a4j:outputPanel layout="block"> <rich:dataScroller for="repeat" render="panel" fastStep="3"/> </a4j:outputPanel> </h:panelGrid> </h:form> </ui:composition>
package org.richfaces.demo.tables; import java.io.Serializable; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.SessionScoped; import org.richfaces.demo.tables.model.capitals.Capital; @ManagedBean @SessionScoped public class CapitalsBean implements Serializable { private static final long serialVersionUID = -1509108399715814302L; @ManagedProperty(value = "#{capitalsParser.capitalsList}") private List<Capital> capitals; public List<Capital> getCapitals() { return capitals; } public void setCapitals(List<Capital> capitals) { this.capitals = capitals; } }