Apologies if this isn't text only but Outlook or something else is playing up.
I didn't raise the original question, but I do have a inkling of interest in it's answer.
In Turbine, there is a concept of a screen. A screen is a combination of one velocity template and one screen (Java) class.
The screen class is responsible for populating the velocity context before parsing the screen template.
For example, you'd have the following entities.
HelloWorldScreen.java HelloWorldScreen.vm
HelloWorldScreen.java would populate the velocity context before parsing HelloWorldScreen.vm with that context.
I'm *guessing* what Frans wants to know is if in WebWork can you tie a single class to a single velocity template, so the class always has access to the template's context before it is parsed, no matter what action class is called.
Anyway, hope that makes sense,
If you're calling velocity templates via the dispatcher result, you could implement a TurbineScreen as follows:
public class TurbineScreenVelocityServlet extends WebWorkVelocityServlet { public void mergeTemplate( Template template, Context context, HttpServletResponse response) throws Exception { // look up the class associated with the template // do whatever it is that TurbineScreen does to the context
super.mergeTemplate(template, context, response); } }
If you're trying to avoid calling the dispatcher and use the VelocityResult directly, things are more problematic as there currently isn't any easy way to do this as the method that creates the context currently has no notion of what template will be used. I've commited a minor refactoring that not only cleans up the code, but also should allow you to perform implement something that does this. The refactor just separates out the creation of a Context into its own method in the VelocityResult so that you can now write:
public class TurbineScreenVelocityResult extends VelocityResult { protected Context createContext( VelocityManager velocityManager, OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response, String templateName) { Context context = super.createContext( velocityManager, stack, request, response);
// look up the class associated with the template // do whatever it is that TurbineScreen does to the context
return context; } }
Cheers!
M
------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork