Dashboard > WebWork > ... > Control Tags > sort
  WebWork Log In View a printable version of the current page.  
  sort
Added by Onyeje Bose, last edited by Rainer Hermanns on Apr 13, 2007  (view change)
Labels: 
(None)

Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

Description

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.

Parameters

Name

Required

Default

Type

Description

comparator true   java.util.Comparator The comparator to use
source false   Object/String The iterable source to sort
id false   String The id of the tag element.

Examples

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

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators