| <html><!-- #BeginTemplate "/Templates/ExamplesTemplate.dwt" --> |
| <head> |
| <!-- #BeginEditable "doctitle" --> |
| <title>JSTL: Iterator Tags Examples</title> |
| <!-- #EndEditable --> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <link rel="stylesheet" href="../global.css" type="text/css"> |
| </head> |
| |
| <body bgcolor="#FFFFFF" text="#000000"> |
| <table width="100%" border="0" cellpadding="5"> |
| <tr> |
| <td height="0"><font color="#000099"><b>standard taglib • implementation |
| of the JSP Standard Tag Library</b></font></td> |
| </tr> |
| <tr> |
| <td bgcolor="#CCCCFF"><font size="-1">Examples <a href="../index.html">Introduction</a> |
| • <a href="../elsupport/index.html">General Purpose</a> |
| • <a href="../conditionals/index.html">Conditionals</a> |
| • <a href="index.html">Iterators</a> • |
| <a href="../import/index.jsp">Import</a> • <a href="../format/index.html">I18N |
| & Formatting</a> • <a href="../xml/index.html">XML</a> |
| • <a href="../sql/index.jsp">SQL</a> • <a href="../functions/index.html">Functions</a> |
| • <a href="../tlv/index.html">TLV</a> |
| </font></td> |
| </tr> |
| </table> |
| <!-- #BeginEditable "body" --> |
| <h2>Iterator Tags Examples</h2> |
| |
| <h3>Simple <a href="../ShowSource.jsp?filename=/iterators/Simple.jsp"><img src="../images/code.gif" |
| width="24" height="24" |
| border="0"></a> |
| <a href="Simple.jsp"><img src="../images/execute.gif" width="24" height="24" border="0"></a> |
| </h3> |
| Simply displays the default <code>toString()</code> value of the items in the |
| <code>Customers</code> collection.<br> |
| |
| <h3> Range <a href="../ShowSource.jsp?filename=/iterators/SimpleRange.jsp"><img src="../images/code.gif" |
| width="24" height="24" |
| border="0"></a> |
| <a href="SimpleRange.jsp"><img src="../images/execute.gif" width="24" height="24" border="0"></a> |
| </h3> |
| |
| <p>Another simple example. Similar to the previous one, except that in this case |
| there is no collection to iterate over. The <code>items</code> attribute is |
| optional in the <code><forEach></code> tag. When it is not specified, |
| the range attributes must be used to iterate a specific number of times over |
| the tag's body. In this example, we simply iterate over the integer values specified |
| by the range attributes.</p> |
| |
| <h3>Data Types <a href="../ShowSource.jsp?filename=/iterators/DataTypes.jsp"><img src="../images/code.gif" |
| width="24" height="24" |
| border="0"></a> <a |
| href="DataTypes.jsp"><img src="../images/execute.gif" width="24" height="24" border="0"></a></h3> |
| |
| <p>The <code><forEach></code> tag supports a large number of data types |
| for the collection of objects to iterate over. In this example, we feature the |
| following data types: array of primitives, array of objects, Enumeration, Properties |
| (Map), String (Comma Separated Values).</p> |
| |
| <h3>Iteration Status <a href="../ShowSource.jsp?filename=/iterators/Status.jsp"><img src="../images/code.gif" |
| width="24" height="24" |
| border="0"></a> <a |
| href="Status.jsp"><img src="../images/execute.gif" width="24" height="24" border="0"></a></h3> |
| |
| <p>The iterator tag exposes a wealth of information relative to the iteration |
| taking place. This example features some of that status information.</p> |
| |
| <h3>Collaboration <a href="../ShowSource.jsp?filename=/iterators/Collaboration.jsp"><img |
| src="../images/code.gif" width="24" height="24" border="0"></a> <a href="Collaboration.jsp"><img |
| src="../images/execute.gif" width="24" height="24" border="0"></a></h3> |
| |
| <p>The iterator tags expose interface IteratorTag to allow custom tags to establish |
| implicit collaboration. This example shows two custom tags, <even> and |
| <odd> who take advantage of this implicit collaboration.</p> |
| |
| <h3><forTokens> <a href="../ShowSource.jsp?filename=/iterators/ForTokens.jsp"><img |
| src="../images/code.gif" width="24" height="24" border="0"></a> <a href="ForTokens.jsp"><img |
| src="../images/execute.gif" width="24" height="24" border="0"></a></h3> |
| |
| <p>The <forEach> tag provides the basic iteration capabilities. <forTokens> |
| is a specialization for the handling of Strings of tokens. Essentially the same |
| as <forEach>, except that it only applies to Strings of tokens and that |
| it has an extra attribute "delims" to specify the token delimiter.</p> |
| |
| <h3>Extensibility <a href="../ShowSource.jsp?filename=/iterators/Extensability.jsp"><img |
| src="../images/code.gif" width="24" height="24" border="0"></a> <a href="Extensability.jsp"><img |
| src="../images/execute.gif" width="24" height="24" border="0"></a></h3> |
| |
| <p>JSTL exposes in its API the abstract class LoopTagSupport to facilitate |
| the implementation of custom iterator tags that leverage the standard iteration |
| behavior defined in JSTL. This example shows a custom iterator tag that shows all Locale objects available in the |
| server and a custom conditional sub-tag that |
| display the default locale.</p> |
| |
| <h3>Boundary Case Tests <a href="../ShowSource.jsp?filename=/iterators/BoundaryCases.jsp"><img |
| src="../images/code.gif" width="24" height="24" border="0"></a> |
| <a href="../iterators/BoundaryCases.jsp"><img src="../images/execute.gif" width="24" height="24" border="0"></a> |
| </h3> |
| Failure and minimal value examples.<br> |
| <!-- #EndEditable --> |
| <hr noshade color="#000099"> |
| <table width="100%" border="0" cellpadding="5"> |
| <tr> |
| <td height="24"><font color="#000099"><b>standard taglib • implementation |
| of the JSP Standard Tag Library</b></font></td> |
| </tr> |
| </table> |
| </body> |
| <!-- #EndTemplate --></html> |