I'm pretty sure this is because the buttonbar template is being
processed by the ImportSupport class and therefore has no way to
access the current velocity context (which is what #set is modifying.
It's been a while since i've used this combination of libraries, but i
believe the solution is to set the $buttons value in the $request like
this:

$request.setAttribute('buttons', $buttons1)

This way, the value should be available to all templates processed for
this request, including buttonbar.vm

Let me know if this works.  If not, i have a few other ideas to try.
I'm quite sure this can be done.

On Feb 19, 2008 11:55 AM, Tatyana <[EMAIL PROTECTED]> wrote:
>
> I'm using Struts 1.3.8, Struts Tiles 1.3.8, Velocity 1.4, Velocity Tools 1.3.
>
> I have a problem with #set directive that I hope someone can help me with.
>
> I have a main.vm template (example below) that contains other templates
> defined in tiles.xml file.  I need to be able to reuse the same
> $tiles.buttonbar template with different values for $buttons reference.
>
> I'm trying to reset $buttons list before the $tiles.buttonbar template is
> called.  But it looks like the $tiles.buttonbar template does not see the
> values that are set in main.vm.
>
> How can I make the $tiles.buttonbar template to use different $buttons list
> every time is loaded?  By the way, I do not want to use a macro.  I am
> removing all the macros due to memory issue described in bug
> https://issues.apache.org/jira/browse/VELOCITY-223
>
> Here is my main.vm example:
>
> <html>
> <head>
>         $tiles.importAttributes("request")
> </head>
> <body>
>   $tiles.header
>   #set($buttons = $buttons1)
>
>   $tiles.buttonbar ## first time buttonbar.vm is used
>
>   $tiles.contents
>
> #if($show2)
>   #set ($buttons = $buttons2)
>
>   $tiles.buttonbar ## second time buttonbar.vm is used
>
>   $tiles.subcontent
> #end
> </body>
> </html>
>
> Here is the buttonbar.vm example:
>
> <table><tr>
>         #foreach($button in $buttons)
>           <td onClick='$msg.get($button.action)'>
>                  $msg.get($button.image) $msg.get($button.label)
>             </td>
>         #end
> </tr></table>
>
>
>
>
> --
> View this message in context: 
> http://www.nabble.com/set-directive-and-multiple-velocity-templates-tp15562520p15562520.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to