velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Hamid <>
Subject Velocity macros for recursive display of tree?
Date Wed, 20 Nov 2002 20:48:21 GMT
Can anybody tell me if Velocity would be given to displaying recursive 
structures?  From a brief skimming over the macro language, it appears 
this would be possible by having a macro call itself.

The problem I have is that I would like to display a tree structure 
(folders, files), but the web (or at least JSP) is a notoriously bad 
medium for something like this.  My first cut with pure JSP was pretty 
painful.  Just recently I wrote a generic custom tag to render trees, 
based on the javax.swing.tree package interfaces (TreeModel, TreeNode), 
but still, while being somewhat less painful, it is pretty ugly 
(basically the recursive descent logic is now replaced by the tag (which 
actually forces you to be iterative instead of recursive), but the 
display is still using embedded JSP).

The logic is something like:

render: $node

if $node is a folder
   <li>display $node folder details
   if $node has children
       for each $node child
   display <li>$node file details</li>

of course there is a bit of logic in the display of the node, so I'd 
have to call out to methods on other classes.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message