org.apache.struts2.views.jsp.iterator
Class SortIteratorTag
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
org.apache.struts2.views.jsp.StrutsBodyTagSupport
org.apache.struts2.views.jsp.iterator.SortIteratorTag
- All Implemented Interfaces:
- Serializable, BodyTag, IterationTag, JspTag, Tag
public class SortIteratorTag
- extends StrutsBodyTagSupport
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:
<s:sort comparator="myComparator" source="myList">
<s:iterator>
<!-- do something with each sorted elements -->
<s:property value="..." />
</s:iterator>
</s:sort>
USAGE 2:
<s: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
}
%>
- See Also:
SortIteratorFilter
,
Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
comparatorAttr
String comparatorAttr
sourceAttr
String sourceAttr
sortIteratorFilter
SortIteratorFilter sortIteratorFilter
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
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.