I am using velocity for my output and have found the component tags to be useful. I have found, however, that I'm not quite sure about how the velocity context and the value stack interact. Specifically, how can I get a component directive to work cleanly with a variable that exists in the velocity context?
An example of where this problem arises is if you want a particular component to be displayed multiple times, once per iteration of a collection. The proper way to iterate through a collection in velocity is using the #foreach directive, as shown: #foreach ($item in $myCollection) $item.display #end The problem is if you want to use the object referenced by "$item" in the example above as something to supply to a component using the velocity version of the component tag. #bodytag(Component "template=myTemplate.vm") #param("param1" "HOW DO I PUT $item HERE?") #end If you just put "$item" in the value portion of the #param directive, it looks like it just supplies the value of "$item.toString()" rather than the reference to "$item" itself. I've found a way that works, but it seems kludgey to me. I basically push the "$item" object onto the stack, then pop it off. It makes for a bit more code than I'd like, but it seems to work. Here's an example: #foreach ($section in $currentPage.sections) $stack.push($section) #bodytag(Component "template=pageset/section.vm") #param("section" "top") #param("object" "currentObject") #end #set ($section = $stack.pop()) #end I don't know how the velocity directives work exactly, but this is the kind of thing that I would think would work a little nicer: #bodytag(Component "template=pageset/section.vm") #param("section" $section) #param("object" $currentObject) #end Please tell me I'm making this more complicated, and that there's an easier way! Thanks, Drew ------------------------------------------------------- This SF.Net email sponsored by: ApacheCon 2003, 16-19 November in Las Vegas. Learn firsthand the latest developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more! http://www.apachecon.com/ _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork