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
}
%>
|