Thank you Hans,
that trick will do for some of the sorting problems I have. By the way
bought your book and have toasted a lot of bread since ;). My JSP bible.
Xtags has a built in sort function. Might sorting be considered in future
releases of jstl?
And one more for the weekend, what would be the best way to get a total sum
of N numbers from a xml query (jstl of course)?
Thanks,
�orgils V�lundarson (if you see the letter � it is pronounced Th)
At 08:45 15.8.2002 -0700, you wrote:
>Shawn Bayern wrote:
>>On Thu, 15 Aug 2002, �orgils V�lundarson wrote:
>>
>>>how can I store multiple data items from jstl xml query in a vector to
>>>be used later in a servlet to f.x. sort the data?
>>
>>I'm not sure what "f.x." means, but in general, this sort of operation is
>>probably best performed entirely in a servlet. Servlets are better suited
>>than JSTL for building and performing complex operations on data
>>structures.
>
>I agree with Shawn that complex code should go in some other type of
>component, but for simple sorts I sometimes use this trick:
>
> <%-- Create a TreeMap: it sorts its keys automatically --%>
> <jsp:useBean id="sorted" class="java.util.TreeMap" />
>
> <%-- Add the values to be sorted as keys in the TreeMap --%>
> <c:set target="${sorted}" property="z" value="" />
> <c:set target="${sorted}" property="b" value="" />
> <c:set target="${sorted}" property="x" value="" />
>
> <%-- Use the sorted keys --%>
> <c:forEach items="${sorted}" var="c">
> <c:out value="${c.key}" />
> </c:forEach>
>
>Hans
>--
>Hans Bergsten [EMAIL PROTECTED]
>Gefion Software http://www.gefionsoftware.com
>JavaServer Pages http://TheJSPBook.com
>
>
>--
>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Kve�ja,
�orgils V�lundarson
Krabbameinsf�lag �slands, Krabbameinsskr�
Beinn s�mi: 540 1973
netfang: [EMAIL PROTECTED]
gsm: 698 5302
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>