Drew,

We've just been playing with this today and I have to say I agree that this
makes things much neater - good idea!

It would break existing Velocity uses though. Are you using the latest WW2
CVS with Velocity? (We're having problems upgrading to it)

Cheers,
Mike

On 12/11/03 5:24 PM, "Drew McAuliffe" ([EMAIL PROTECTED]) penned the words:

> I couldn't find my previous email on the SF list yet to keep this reply
> there, but I believe I understand now why the velocity directives act the
> way they do. In my post, I indicated that it would be easier to pass objects
> from the velocity context into bodytag params if you could do so without
> popping things onto the stack. For example, where this works now,
> 
> #foreach ($item in $myItems)
> $stack.push($item)
> #bodytag(Component template="mytemplate.vm")
> #param("param1" "$item")
> #end
> #set ($item = $stack.pop())
> #end
> , the following would be preferable:
> 
> #foreach ($item in $myItems)
> #bodytag(Component template="mytemplate.vm")
> #param("param1" $item)
> #end
> #end
> 
> The difference is that in the second example, the reference to $item isn't
> quoted, and the value is passed into the velocity context for evaluation. I
> now understand why this doesn't work like that. In the ParamDirective.render
> method, the "value" portion is evaluated against the valueStack:
> 
>           if (stack != null) {
>               value = stack.findValue(value.toString());
>           }
> 
> So, even if you pass in just $item, without quotes, it will be converted to
> a string and its string contents evaluated against the value stack, then
> passed to the velocity context for rendering.
> 
> I would suggest removing these lines in order to simplify the use of the
> #bodytag directive. By doing so, the simpler, more velocity-intuitive syntax
> I've shown would work. If you truly wanted to evaluate something against the
> valueStack, you could manually as follows:
> #foreach ($item in $myItems)
> #bodytag(Component template="mytemplate.vm")
> #param("param1" $stack.findValue($item))
> #end
> #end
> 
> Now, I'm not sure if this would break anything else, or if there is a better
> way to do this, or even if it would work (I'm checking on that now), but I
> thought I'd throw some more info out there.
> 
> 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



-------------------------------------------------------
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

Reply via email to