craigmcc 01/03/04 18:16:39 Modified: src/doc struts-logic.xml Log: Clearly document the data types over which the <logic:iterate> tag can run, and add information about what you need to do when iterating over a java.util.Map. Revision Changes Path 1.7 +33 -2 jakarta-struts/src/doc/struts-logic.xml Index: struts-logic.xml =================================================================== RCS file: /home/cvs/jakarta-struts/src/doc/struts-logic.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- struts-logic.xml 2001/02/09 19:33:10 1.6 +++ struts-logic.xml 2001/03/05 02:16:39 1.7 @@ -389,11 +389,42 @@ <li>As the property, specified by the <code>property</code>, of the JSP bean specified by the <code>name</code> attribute.</li> </ul> + + <p>The collection to be iterated over MUST conform to one of the following + requirements in order for iteration to be successful:</p> + <ul> + <li>An array of Java objects (but not primitive data types such as + "int")</li> + <li>An implementation of <code>java.util.Collection</code>, including + <code>ArrayList</code> and <code>Vector</code>.</li> + <li>An implementation of <code>java.util.Iterator</code>.</li> + <li>An implementation of <code>java.util.Map</code>, including + <code>HashMap</code>, <code>Hashtable</code>, and + <code>TreeMap</code>. <strong>NOTE</strong> - See below for + additional information about accessing Maps.</li> + </ul> + + <p>Normally, each object exposed by the iterate tag is an element + of the underlying collection you are iterating over. However, if you + iterate over a <code>Map</code>, the exposed object is of type + <code>Map.Entry</code> that has two properties:</p> + <ul> + <li><code>key</code> - The key under which this item is stored in the + underlying Map.</li> + <li><code>value</code> - The value that corresponds to this key.</li> + </ul> + + <p>So, if you wish to iterate over the values of a Hashtable, you would + implement code like the following:</p> + <code> + <logic:iterate id="element" name="myhashtable"/><br/> + Next element is <bean:write name="element" property="value"/><br/> + </logic:iterate> + </code> + <p><strong>WARNING</strong> - Currently, this tag cannot deal with arrays of primitive data types. Only arrays of Java objects (including Strings) are supported.</p> - <p><strong>WARNING</strong> - This tag requires a Java2 (JDK 1.2 or later) - runtime environment.</p> </info> <attribute>