org.apache.struts.taglib.logic

Class IterateTag

public class IterateTag extends BodyTagSupport

Custom tag that iterates the elements of a collection, which can be either an attribute or the property of an attribute. The collection can be any of the following: an array of objects, an Enumeration, an Iterator, a Collection (which includes Lists, Sets and Vectors), or a Map (which includes Hashtables) whose elements will be iterated over.

Version: $Rev: 56513 $ $Date: 2004-11-03 19:20:47 +0000 (Wed, 03 Nov 2004) $

Field Summary
protected Objectcollection
The collection over which we will be iterating.
protected Stringid
The name of the scripting variable to be exposed.
protected StringindexId
The name of the scripting variable to be exposed as the current index.
protected Iteratoriterator
Iterator of the elements of this collection, while we are actually running.
protected Stringlength
The length value or attribute name (<=0 means no limit).
protected intlengthCount
The number of elements we have already rendered.
protected intlengthValue
The actual length value (calculated in the start tag).
protected static MessageResourcesmessages
The message resources for this package.
protected Stringname
The name of the collection or owning bean.
protected Stringoffset
The starting offset (zero relative).
protected intoffsetValue
The actual offset value (calculated in the start tag).
protected Stringproperty
The property name containing the collection.
protected Stringscope
The scope of the bean specified by the name property, if any.
protected booleanstarted
Has this tag instance been started?
protected Stringtype
The Java class of each exposed element of the collection.
Method Summary
intdoAfterBody()
Make the next collection element available and loop, or finish the iterations if there are no more elements.
intdoEndTag()
Clean up after processing this enumeration.
intdoStartTag()
Construct an iterator for the specified collection, and begin looping through the body once per element.
ObjectgetCollection()
StringgetId()
intgetIndex()

Return the zero-relative index of the current iteration through the loop.

StringgetIndexId()
StringgetLength()
StringgetName()
StringgetOffset()
StringgetProperty()
StringgetScope()
StringgetType()
voidrelease()
Release all allocated resources.
voidsetCollection(Object collection)
voidsetId(String id)
voidsetIndexId(String indexId)
voidsetLength(String length)
voidsetName(String name)
voidsetOffset(String offset)
voidsetProperty(String property)
voidsetScope(String scope)
voidsetType(String type)

Field Detail

collection

protected Object collection
The collection over which we will be iterating.

id

protected String id
The name of the scripting variable to be exposed.

indexId

protected String indexId
The name of the scripting variable to be exposed as the current index.

iterator

protected Iterator iterator
Iterator of the elements of this collection, while we are actually running.

length

protected String length
The length value or attribute name (<=0 means no limit).

lengthCount

protected int lengthCount
The number of elements we have already rendered.

lengthValue

protected int lengthValue
The actual length value (calculated in the start tag).

messages

protected static MessageResources messages
The message resources for this package.

name

protected String name
The name of the collection or owning bean.

offset

protected String offset
The starting offset (zero relative).

offsetValue

protected int offsetValue
The actual offset value (calculated in the start tag).

property

protected String property
The property name containing the collection.

scope

protected String scope
The scope of the bean specified by the name property, if any.

started

protected boolean started
Has this tag instance been started?

type

protected String type
The Java class of each exposed element of the collection.

Method Detail

doAfterBody

public int doAfterBody()
Make the next collection element available and loop, or finish the iterations if there are no more elements.

Throws: JspException if a JSP exception has occurred

doEndTag

public int doEndTag()
Clean up after processing this enumeration.

Throws: JspException if a JSP exception has occurred

doStartTag

public int doStartTag()
Construct an iterator for the specified collection, and begin looping through the body once per element.

Throws: JspException if a JSP exception has occurred

getCollection

public Object getCollection()

getId

public String getId()

getIndex

public int getIndex()

Return the zero-relative index of the current iteration through the loop. If you specify an offset, the first iteration through the loop will have that value; otherwise, the first iteration will return zero.

This property is read-only, and gives nested custom tags access to this information. Therefore, it is only valid in between calls to doStartTag() and doEndTag().

getIndexId

public String getIndexId()

getLength

public String getLength()

getName

public String getName()

getOffset

public String getOffset()

getProperty

public String getProperty()

getScope

public String getScope()

getType

public String getType()

release

public void release()
Release all allocated resources.

setCollection

public void setCollection(Object collection)

setId

public void setId(String id)

setIndexId

public void setIndexId(String indexId)

setLength

public void setLength(String length)

setName

public void setName(String name)

setOffset

public void setOffset(String offset)

setProperty

public void setProperty(String property)

setScope

public void setScope(String scope)

setType

public void setType(String type)
Copyright © 2000-2008 - The Apache Software Foundation