com.opensymphony.webwork.views.jsp
Class IteratorTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended bycom.opensymphony.webwork.views.jsp.WebWorkBodyTagSupport
              extended bycom.opensymphony.webwork.views.jsp.IteratorTag
All Implemented Interfaces:
BodyTag, IterationTag, Serializable, Tag

public class IteratorTag
extends WebWorkBodyTagSupport

Iterator will iterate over a value. An iterable value can be either of: java.util.Collection, java.util.Iterator, java.util.Enumeration, java.util.Map, array.

Example:

 <ww:iterator value="days">
   <p>day is: <ww:property/></p>
 </ww:iterator>
 

The above example retrieves the value of the getDays() method of the current object on the value stack and uses it to iterate over. The <ww:property/> tag prints out the current value of the iterator.

The following example uses a BeanTag and places it into the ActionContext. The iterator tag will retrieve that object from the ActionContext and then calls its getDays() method as above. The status attribute is also used to create a IteratorStatus object, which in this example, its odd() method is used to alternate row colours:

 <ww:bean name="'com.opensymphony.webwork.example.IteratorExample'" id="it">
   <ww:param name="'day'" value="'foo'"/>
   <ww:param name="'day'" value="'bar'"/>
 </ww:bean>
 

<table border="0" cellspacing="0" cellpadding="1"> <tr> <th>Days of the week</th> </tr>

<ww:iterator value="#it.days" status="rowstatus"> <tr> <ww:if test="#rowstatus.odd == true"> <td style="background: grey"><ww:property/></td> </ww:if> <ww:else> <td><ww:property/></td> </ww:else> </tr> </ww:iterator> </table>

Version:
$Revision: 1.14 $
Author:
$Author: jcarreira $, Rick Salsa (rsal@mb.sympatico.ca)
See Also:
Serialized Form

Field Summary
protected  Iterator iterator
           
protected  Object oldStatus
           
protected  IteratorStatus status
           
protected  String statusAttr
           
protected  IteratorStatus.StatusState statusState
           
protected  String value
           
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, 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
IteratorTag()
           
 
Method Summary
 int doAfterBody()
           
 int doStartTag()
           
 void setStatus(String name)
           
 void setValue(String value)
           
 
Methods inherited from class com.opensymphony.webwork.views.jsp.WebWorkBodyTagSupport
findString, findValue, findValue, getStack, toString
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doEndTag, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, 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

iterator

protected Iterator iterator

status

protected IteratorStatus status

oldStatus

protected Object oldStatus

statusState

protected IteratorStatus.StatusState statusState

statusAttr

protected String statusAttr

value

protected String value
Constructor Detail

IteratorTag

public IteratorTag()
Method Detail

setStatus

public void setStatus(String name)

setValue

public void setValue(String value)

doAfterBody

public int doAfterBody()
                throws JspException
Throws:
JspException

doStartTag

public int doStartTag()
               throws JspException
Throws:
JspException

WebWork Project Page