logic
Tag iterate


Repeat the nested body content of this tag over a specified collection.

Repeats the nested body content of this tag once for every element of the specified collection, which must be an Iterator, a Collection, a Map (whose values are to be iterated over), or an array. The collection to be iterated over must be specified in one of the following ways:

The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:

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 Map, the exposed object is of type Map.Entry that has two properties:

So, if you wish to iterate over the values of a Hashtable, you would implement code like the following:

<logic:iterate id="element" name="myhashtable">
Next element is <bean:write name="element" property="value"/>
</logic:iterate>

If the collection you are iterating over can contain null values, the loop will still be performed but no page scope attribute (named by the id attribute) will be created for that loop iteration. You can use the <logic:present> and <logic:notPresent> tags to test for this case.



Tag Information
Tag Classorg.apache.struts.taglib.logic.IterateTag
TagExtraInfo Classorg.apache.struts.taglib.logic.IterateTei
Body ContentJSP
Display NameNone

Attributes
NameRequiredRequest-timeTypeDescription
collectionfalsetruejava.lang.Object

A runtime expression that evaluates to a collection (conforming to the requirements listed above) to be iterated over.

idtruefalsejava.lang.String

The name of a page scope JSP bean that will contain the current element of the collection on each iteration, if it is not null.

indexIdfalsefalsejava.lang.String

The name of a page scope JSP bean that will contain the current index of the collection on each iteration.

lengthfalsetruejava.lang.String

The maximum number of entries (from the underlying collection) to be iterated through on this page. This can be either an integer that directly expresses the desired value, or the name of a JSP bean (in any scope) of type java.lang.Integer that defines the desired value. If not present, there will be no limit on the number of iterations performed.

namefalsetruejava.lang.String

The name of the JSP bean containing the collection to be iterated (if property is not specified), or the JSP bean whose property getter returns the collection to be iterated (if property is specified).

offsetfalsetruejava.lang.String

The zero-relative index of the starting point at which entries from the underlying collection will be iterated through. This can be either an integer that directly expresses the desired value, or the name of a JSP bean (in any scope) of type java.lang.Integer that defines the desired value. If not present, zero is assumed (meaning that the collection will be iterated from the beginning.

propertyfalsetruejava.lang.String

Name of the property, of the JSP bean specified by name, whose getter returns the collection to be iterated.

scopefalsetruejava.lang.String

The bean scope within which to search for the bean named by the name property, or "any scope" if not specified.

typefalsetruejava.lang.String

Fully qualified Java class name of the element to be exposed through the JSP bean named from the id attribute. If not present, no type conversions will be performed. NOTE: The actual elements of the collection must be assignment-compatible with this class, or a request time ClassCastException will occur.


Variables
No Variables Defined.


Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.