Re: In VTL, simply reverse a list with java.util.Collection static method
Nathan Bubna <[email protected]>
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <CAFyaDjHqjhgmxL-63DafBthrh11wtbzV3L7OE+3XiNriiczxwQ@mail.gmail.com> |
http://velocity.apache.org/engine/devel/developer-guide.html#supportforstaticclasses On Mon, May 6, 2013 at 12:15 PM, Travis P <[email protected]> wrote: > 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