The rich:togglePanel component can leverage a4j:repeat as a child component to dynamically generate toggle panel items.
The following example shows the rich:togglePanel dynamically generated from list of skins:
<!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"> <h:form id="form"> <rich:togglePanel id="dynamicPanels" switchType="ajax" activeItem="#{dynamicPanelBean.activeTab}"> <a4j:repeat value="#{skinBean.skins}" var="skinName"> <rich:togglePanelItem name="#{skinName}"> <rich:panel header="Skin: #{skinName}"> <h:panelGrid columns="2"> <h:outputText value="Enter Name:" /> <h:inputText id="input" /> <h:outputText value="Enter you interests:" /> <h:inputTextarea cols="17" rows="3" /> <h:outputText value="Choose your favourite color" /> <h:selectOneMenu> <f:selectItem itemLabel="Red" itemValue="0" /> <f:selectItem itemLabel="Black" itemValue="1" /> <f:selectItem itemLabel="Green" itemValue="2" /> <f:selectItem itemLabel="White" itemValue="3" /> </h:selectOneMenu> </h:panelGrid> <hr /> <h:commandButton value="Switch to #{skinName} skin"> <f:param name="skin" value="#{skinName}" /> </h:commandButton> </rich:panel> </rich:togglePanelItem> </a4j:repeat> </rich:togglePanel> <br /> <a4j:commandButton value="<<Previous"> <rich:toggleControl targetItem="@prev" targetPanel="dynamicPanels" /> </a4j:commandButton> <a4j:commandButton value="Next >>"> <rich:toggleControl targetItem="@next" targetPanel="dynamicPanels" /> </a4j:commandButton> </h:form> </ui:composition>