Now I have some questions :-)
What IF the velocity template is accessed directly, how can one know, in the template, if this is happening?
What is the difference between using $stack.findValue("$name") and $name directly?
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?
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}?
I.e for using the OGNL EL from velocity one goes thru the $stack.findValue() method? ( I've seen usage such as stack.findValue("new Bean()") )
----
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.
Another problem is where I should put the ToolBox context into the VelocityContext?
Any help or pointer to documentation would be appreciated :-)
Thanks a lot! Jonas
Matt Ho wrote:
With regards to the data contained within the ValueStack, I've posted the following up on the wiki under:
http://wiki.opensymphony.com/space/Using+WebWork+2+Tags+from+Velocity
cWebWork2 contains the following items by default in the ValueStack:
* req - the current HttpServletRequest * res - the current HttpServletResponse * stack - the current OgnlValueStack * ognl - an instance of OgnlTool * ui - a (now deprecated) instance of a ui tag renderer
Additionally, WebWork uses a customized VelocityContext that allows properties from the value stack to be directly accessed. This means that if you have the following Action:
public class SampleAction implements Action { ...
public String getName() { … } public Address getAddress() { … } }
You can, from Velocity, access name and address as $name and $address respectively.
--------
I'm definitely in agreement on enabling VelocityTools to work with WW2 either by default or as a drop-in addon though I haven't had a moment yet to do this. If you're interested in doing this, I would highly encourage you :)
M
Jonas Eriksson wrote:
Hi!
First, WebWork2 is looking really promising, great work!
Second, I have not used WebWork1 but tried Struts a year ago and when I read about WebWork I thought "this is easy, compared to Struts". The decision fell on WebWork2 and the Velocity view. I feel this combination is very powerful but where's the documentation... The ww1 documentation serves as a good and basic understanding of how ww2 (should/will) work and then there's the wiki which is good, sometimes ;). What should be pointed out in some kind of documentation is:
- What is contained in the velocity context after action execution and after direct vm request?
- Which functionality (tags and macros) are carried over from ww1, and which are new? There is a JIRA issue concerning this (with MINOR priority, should be MAJOR IMO); http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-251
"Velocity view support" without good tags and helper classes is no Velocity support from a newcomer's point of view.
No more whining... but I would like to know if anyone is interested in using Velocity Tools, mostly the VelocityLayoutServlet, in ww2?
I like the idea of using vm templates to build a page layout. Very simple but still powerful. I have made some ugly changes to ww2 to make it work with Velocity Tools (not the ToolBox, yet). Is there any chance at all there will be support for VelocityLayoutServlet (or similiar 2-pass rendering style) in ww2?
One more thing... is there anything similar to the Velocity Tools ToolBox in ww2? (the ToolBox binds, via xml, instances/values to the velocity context)
Cheers! :-)
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
------------------------------------------------------- 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
------------------------------------------------------- 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