I'm not sure I follow this. The update I made was yesterday off of a CVS
update from the day before. If the render stuff isn't called, how do the
custom velocity directives work? This is a question based on some ignorace
about how velocity itself works in conjunction with webwork.

Couldn't the jsp tags manually make a call to $stack.findValue() and the
velocity directive be kept more velocity-friendly? The suggestion I made
seems (to me) to work more in line with the way velocity itself works, where
you pass in objects and strings and the directives themselves don't do
anything unexpected with them. The idea of taking anything passed into the
velocity directive and automatically calling stack.findValue() on it seems
to be an unexpected consequence of using the directive, and difficult to
understand without thorough knowledge of the inner workings of the code (and
thus potentially bad). IMHO. When you say that the tags need this, I can
understand that because a tag param value is always a string and not
potentially an object like in velocity. But couldn't we update the templates
to call stack.findValue() on whatever they get from their value strings?

If we can't change the existing param directive to just take what it is
given without calling stack.findValue, then perhaps there should be two
velocity directives for #param, one that automatically evaluates its
contents against the stack and another that doesn't. Maybe naming would be
#valueparam and #param or something similar. If we do this, I think the
naming is important to distinguish between the use of each, since neither
one really seems to have more of a claim than the other to the simple
"#param" name.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Patrick Lightbody
Sent: Wednesday, November 12, 2003 7:46 PM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] More about velocity directives

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