org.apache.struts.taglib.logic
Class IterateTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.apache.struts.taglib.logic.IterateTag
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, Tag
Direct Known Subclasses:
ELIterateTag, NestedIterateTag

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: 471754 $ $Date: 2004-11-03 14:20:47 -0500 (Wed, 03 Nov 2004) $
See Also:
Serialized Form

Field Summary
protected  Object collection
          The collection over which we will be iterating.
protected  String id
          The name of the scripting variable to be exposed.
protected  String indexId
          The name of the scripting variable to be exposed as the current index.
protected  Iterator iterator
          Iterator of the elements of this collection, while we are actually running.
protected  String length
          The length value or attribute name (<=0 means no limit).
protected  int lengthCount
          The number of elements we have already rendered.
protected  int lengthValue
          The actual length value (calculated in the start tag).
protected static MessageResources messages
          The message resources for this package.
protected  String name
          The name of the collection or owning bean.
protected  String offset
          The starting offset (zero relative).
protected  int offsetValue
          The actual offset value (calculated in the start tag).
protected  String property
          The property name containing the collection.
protected  String scope
          The scope of the bean specified by the name property, if any.
protected  boolean started
          Has this tag instance been started?
protected  String type
          The Java class of each exposed element of the collection.
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
IterateTag()
           
 
Method Summary
 int doAfterBody()
          Make the next collection element available and loop, or finish the iterations if there are no more elements.
 int doEndTag()
          Clean up after processing this enumeration.
 int doStartTag()
          Construct an iterator for the specified collection, and begin looping through the body once per element.
 Object getCollection()
           
 String getId()
           
 int getIndex()
          Return the zero-relative index of the current iteration through the loop.
 String getIndexId()
           
 String getLength()
           
 String getName()
           
 String getOffset()
           
 String getProperty()
           
 String getScope()
           
 String getType()
           
 void release()
          Release all allocated resources.
 void setCollection(Object collection)
           
 void setId(String id)
           
 void setIndexId(String indexId)
           
 void setLength(String length)
           
 void setName(String name)
           
 void setOffset(String offset)
           
 void setProperty(String property)
           
 void setScope(String scope)
           
 void setType(String type)
           
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getParent, getValue, getValues, removeValue, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

messages

protected static MessageResources messages
The message resources for this package.


iterator

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


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).


offsetValue

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


started

protected boolean started
Has this tag instance been started?


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.


length

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


name

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


offset

protected String offset
The starting offset (zero relative).


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.


type

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

Constructor Detail

IterateTag

public IterateTag()
Method Detail

getCollection

public Object getCollection()

setCollection

public void setCollection(Object collection)

getId

public String getId()
Overrides:
getId in class TagSupport

setId

public void setId(String id)
Overrides:
setId in class TagSupport

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()

setIndexId

public void setIndexId(String indexId)

getLength

public String getLength()

setLength

public void setLength(String length)

getName

public String getName()

setName

public void setName(String name)

getOffset

public String getOffset()

setOffset

public void setOffset(String offset)

getProperty

public String getProperty()

setProperty

public void setProperty(String property)

getScope

public String getScope()

setScope

public void setScope(String scope)

getType

public String getType()

setType

public void setType(String type)

doStartTag

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

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doAfterBody

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

Specified by:
doAfterBody in interface IterationTag
Overrides:
doAfterBody in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doEndTag

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

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

release

public void release()
Release all allocated resources.

Specified by:
release in interface Tag
Overrides:
release in class BodyTagSupport


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.