com.opensymphony.webwork.views.jsp.iterator
Class SortIteratorTag
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
com.opensymphony.webwork.views.jsp.WebWorkBodyTagSupport
com.opensymphony.webwork.views.jsp.iterator.SortIteratorTag
- All Implemented Interfaces:
- Serializable, BodyTag, IterationTag, Tag
public class SortIteratorTag
- extends WebWorkBodyTagSupport
NOTE: JSP-TAG
A Tag that sorts a List using a Comparator both passed in as the tag attribute.
If 'id' attribute is specified, the sorted list will be placed into the PageContext
attribute using the key specified by 'id'. The sorted list will ALWAYS be
pushed into the stack and poped at the end of this tag.
- id (String) - if specified, the sorted iterator will be place with this id under page context
- source (Object) - the source for the sort to take place (should be iteratable) else JspException will be thrown
- comparator* (Object) - the comparator used to do sorting (should be a type of Comparator or its decendent) else JspException will be thrown
USAGE 1:
<ww:sort comparator="myComparator" source="myList">
<ww:iterator>
<!-- do something with each sorted elements -->
<ww:property value="..." />
</ww:iterator>
</ww:sort>
USAGE 2:
<ww:sort id="mySortedList" comparator="myComparator" source="myList" />
<%
Iterator sortedIterator = (Iterator) pageContext.getAttribute("mySortedList");
for (Iterator i = sortedIterator; i.hasNext(); ) {
// do something with each of the sorted elements
}
%>
- Author:
- Rickard Oberg (rickard@dreambean.com), tm_jee (tm_jee(at)yahoo.co.uk)
- See Also:
SortIteratorFilter
,
Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SortIteratorTag
public SortIteratorTag()
setComparator
public void setComparator(String comparator)
setSource
public void setSource(String source)
doStartTag
public int doStartTag()
throws JspException
- Specified by:
doStartTag
in interface Tag
- Overrides:
doStartTag
in class BodyTagSupport
- Throws:
JspException
doEndTag
public int doEndTag()
throws JspException
- Specified by:
doEndTag
in interface Tag
- Overrides:
doEndTag
in class BodyTagSupport
- Throws:
JspException