Lists
Besides subpanels and parameters, a panel may also contain lists. A list contains a sequence of items containing panels, parameters and - you guessed it - lists. The Calyxo Panels custom tag library provides a tag that allows templates to iterate over a list in its corresponding definition. Lists may be used to define menu structures, a sequence of panels to be layout in a specific way, and more.
As an example, consider the following panel definition:
<panel name="/blurb" template="/jsp/column.jsp">
<list name="items">
<item>
<param name="head" value="Item 1"/>
<panel name="body" template="/jsp/blurb1.jsp"/>
</item>
<item>
<param name="head" value="Item 2"/>
<panel name="body" template="/jsp/blurb2.jsp"/>
</item>
<item>
<param name="head" value="Item 3"/>
<panel name="body" template="/jsp/blurb3.jsp"/>
</item>
</list>
</panel>
The /blurb panel defines the items list, containing three items, each containing a parameter named head and a panel named body.
The layout template /jsp/column.jsp iterates over the list:
<jsp:root version="2.0"
xmlns:panels="http://calyxo.odysseus.de/jsp/panels"
xmlns:jsp="http://java.sun.com/JSP/Page">
<panels:list name="items">
<h4>${calyxo.panels.param.head}</h4>
<p>
<panels:panel name="body"/>
</p>
</panels:list>
</jsp:root>
During iteration, the current item behaves as if its contained elements (head and body) were moved up to the panel containing the list. Thus, when rendering /blurb, the above template creates paragraphs containing contents of /jsp/blurb1.jsp with heading "Item 1", /jsp/blurb2.jsp with heading "Item 2" and /jsp/blurb3.jsp with heading "Item 3".


