This tag library includes useful iteration tags that complement the set of standard iterator tags of the JSP Standard Tag Library (JSTL).
<forCategories>
This iterator tag is exactly like <forEach>, with the addition
that it supports the concept of categories. For instance, in the example below,
the collection contains a list of athletes sorted by their associated
country. By using the <forCategories> tag, it is possible to display distinctive
headers and footers whenever a new country is encountered in the list.
<iter:forCategories var="athlete" items="${athletes}">
<iter:category value="${athlete.country}">
<iter:header>
<h3><c:out value="${athlete.country}"/></h3>
</iter:header>
<iter:body>
<c:out value="${athlete.name}"/><br>
</iter:body>
<iter:footer>
•-•-•-•-•
</iter:footer>
</iter:category>
</iter:forCategories>
<forColumns>
This iterator tag allows the handling of the items of a collection in a columnwise fashion. Each iteration makes available as many items as there are columns, and they are provided such that the ordering sequence is column-wise.
For instance, in the example below, the collection contains a list of athletes sorted by their name. By using the <forColumns> tag, it is possible to display the items of the collection in multiple columns, keeping the display order on a column by column basis.
<table border="1" cellspacing="5">
<iter:forColumns var="athlete" items="${athleteNames}" columns="4">
<tr>
<td><c:out value="${athlete[0].lastName}" default=""/>,
<c:out value="${athlete[0].firstName}" default=""/></td>
<td><c:out value="${athlete[1].lastName}" default=""/><c:if test="${!empty athlete[1]}">,</c:if>
<c:out value="${athlete[1].firstName}" default=""/></td>
<td><c:out value="${athlete[2].lastName}" default=""/><c:if test="${!empty athlete[2]}">,</c:if>
<c:out value="${athlete[2].firstName}" default=""/></td>
<td><c:out value="${athlete[3].lastName}" default=""/><c:if test="{!empty athlete[3]}">,</c:if>
<c:out value="${athlete[3].firstName}" default=""/></td>
</tr>
</iter:forColumns>
</table>
| Armstrong, Lance | Delisle, Laurence | Hineault, Bernard | Puhjo, Dimas |
| Biondi, Matt | Fitzgerald, Thomas | Le Potiron, Jerome | St-Gelais, Vincenzo |
| Bonnehumeur, Marc | Garcia, Bruno | LeFrancois, Jean-Marie | Zalluci, Frederico |
| Borg, Boris | Guttenberg, Moritz | Muller, Hans | |
| Chenard, Line | Hallenbuch, Katherine | Pellegri-Llopart, Eduardo | |
| De Zwirek, Jeremie | Harvey, Pierre | Poirot, Hercule |
This custom tag library requires a servlet container that supports the JavaServer Pages Specification, version 1.2 or higher. It also requires the JSP Standard Tag Library (JSTL).
Follow these steps to configure your web application with this tag library:
<taglib> <taglib-uri>http://jakarta.apache.org/taglibs/iterators-1.0</taglib-uri> <taglib-location>/WEB-INF/iterators.tld</taglib-location> </taglib>
To use the tags from this library in your JSP pages, add the following directive at the top of each page:
<%@ taglib uri="http://jakarta.apache.org/taglibs/iterators-1.0" prefix="foo" %>
where "foo" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
| forCategories | |
| category | |
| body | |
| header | |
| footer | |
| forColumns | |
| forCategories | Availability: | ||||
| Tag Body | JSP | ||||
| Restrictions | None | ||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| items | No | No | |||
| begin | No | No | |||
| end | No | No | |||
| step | No | No | |||
| var | No | No | |||
| varStatus | No | No | |||
| Variables | None | ||||
| Examples | None | ||||
| category | Availability: | ||||
| Tag Body | JSP | ||||
| Restrictions | None | ||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| value | Yes | No | |||
| label | No | No | |||
| Variables | None | ||||
| Examples | None | ||||
| body | Availability: | ||||
| Tag Body | JSP | ||||
| Restrictions | None | ||||
| Attributes | None | ||||
| Variables | None | ||||
| Examples | None | ||||
| header | Availability: | ||||
| Tag Body | JSP | ||||
| Restrictions | None | ||||
| Attributes | None | ||||
| Variables | None | ||||
| Examples | None | ||||
| footer | Availability: | ||||
| Tag Body | JSP | ||||
| Restrictions | None | ||||
| Attributes | None | ||||
| Variables | None | ||||
| Examples | None | ||||
| forColumns | Availability: | ||||
| Tag Body | JSP | ||||
| Restrictions | None | ||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| items | No | No | |||
| var | No | No | |||
| varStatus | No | No | |||
| columns | Yes | No | |||
| Variables | None | ||||
| Examples | None | ||||
See the example application iterators-examples.war for examples of the usage of the tags from this custom tag library.
Java programmers can view the java class documentation for this tag library as javadocs.
Review the complete revision history of this tag library.