Keep in mind that the velocity tags have been changed in the latest CVS
(not beta 1) and so the render() stuff doesn't happen anymore. With
regards to not having the param value be evaluated, that's not an option
because all the JSPs tags _need_ this (since they can't possibly pass in
a value short of an rtexpr). 

However, introducing a secondary param that does this might be an
option.

-Pat

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Drew McAuliffe
Sent: Tuesday, November 11, 2003 10:25 PM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] More about velocity directives

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