com.opensymphony.webwork.views.jsp
Class IteratorTag
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
com.opensymphony.webwork.views.jsp.WebWorkBodyTagSupport
com.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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
IteratorTag
public IteratorTag()
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