In VTL, simply reverse a list with java.util.Collection static method
Travis P <[email protected]>
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <CAO76jq9D3bnx5n6DZyeTmEaOPDeDFSkkV6b_nJxmk+-Od1SONw@mail.gmail.com> |
Via web searching, I've found quite a few people reversing lists by writing
out loops.
Seems to me, we should be able to something like:
#set ($lst = ["a","b","c"])
#set ($revlst = $lst)
$Collection.reverse($revlst)
where $Collection.reverse refers to the java.util.Collections static method
static void*reverse<http://w3.hursley.ibm.com/java/docs/jdk5.0/api/java/util/Collections.html#reverse(java.util.List)>
*(List <http://w3.hursley.ibm.com/java/docs/jdk5.0/api/java/util/List.html>
<?> list)
Reverses the order of the elements in the specified list.
but I don't see any way to do that without writing a custom tool. Which
seems heavy-handed for such a basic thing. Am I missing something?
(I'm using velocity-1.7, velocity-tools-view-2.0, running on tomcat-7.0.39)
-Travis