Matt Ho wrote:


Jonas Eriksson wrote:

Great!

Now I have some questions :-)

What IF the velocity template is accessed directly, how can one know, in the template, if this is happening?


Do you mean how can one tell the difference between:

#parse( "/my/template.vm" )

and

#tag( Component "template=/my/template.vm" )

$tag won't be defined in the former.

No, what I meant was: Is there any way of knowing if the template is rendered thru the WebWorkVelocityLayout (accessing .vm) or thru an .action. But... right now I don't remember exactly why this would be of any importance... :-)



What is the difference between using $stack.findValue("$name") and $name directly?


The short answer is that there are some OGNL expressions that can't be resolved using a $name syntax only. For example, when debugging, it's often a good idea to start with

$stack.findValue("[0]")

to see what the value stack looks like. $[0] isn't a valid velocity expression. Also, while you could say $stack.findValue("getText('foo')"), $getText('foo') won't work under velocity.

WRT to your question. $name is more equivalent to $stack.findValue("name"). With $stack.findValue("$name"), velocity will first resolve $name and then pass that to $stack.findValue()

Is stating $name going to search down the stack so if it is not found in the top element (the Action I suppose..) it will continue?


yes. $name will search through the stack til it finds a match or runs out of stack.

Regarding the OGNL section in the wiki - what is the relationship of a velocity reference ($ref) and the OGNL EL (with xwork ext). For example; [1].name has to be written using $stack.findValue("[1].name") and can not be referenced by something like ${[1].name}?


No. Again, this is not valid velocity syntax.

Regarding VelocityTools.
I've created a WebWorkVelocityLayoutServlet that extends the VelocityLayoutServlet and contains almost exactly the code in WebWorkVelocityServlet. That is not so ugly I think... but to handle a direct request for a template (not thru Action) I had to use the special mergeTemplate method in the VelocityLayoutServlet in the new VelocityLayoutResult class I made. This is not how this should be done but I can't get a grip on the difference between the two request cases.


Would you mind posting the code? I think that would make this easier to go through :)

M

I created a jira issue where I attached the two new files. http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-288

Regards
Jonas



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to