Don
Ted Husted wrote:
On Tue, 15 Feb 2005 17:26:21 -0800, Don Brown wrote:
For implementation, I would favor adding a ActionContext.getViewContext() method that returns a generic Context map. The request processing chain could have a command or chain of commands after the action executes to process the ViewContext, adding in any other objects the view might need.
This might be the best way to say it:
* ViewContext is a non-static TagUtils class
made available through request-scope.
Originally, I was thinking of the ViewContext as an augmented Context, like the ActionContext. Essentially, the portion of the Struts API that we need to write the taglibs: Methods like getLocale and getTokenName, but without irrelevant methods that a rendering technology doesn't need.
When I started to looking at the Velocity Tools for an example of just such an API, I realized that the tool mechanism itself is also quite useful. Rather than come up with a static API, we could take the Velocity route and put objects (or "tool") into the ViewContext. The tools would then provide access to the Struts internals, rather than the context itself.
A synergistic approach might be to augment the ViewContext with the methods we need to write tags and other rendering devices, but implement those methods as a facade that calls into a standard set of tool objects.
So a call to
* viewContext.getLocale
might be implemented as
* return textTool.getLocale(();
where "textTool" is a private member instantiated when the ViewContext is created for this request. The same TextTool would also be available under a standard key through ViewContext.get(String).
We would plug our own "framework" tools into ViewContext and let applications do the same with their own tools.
The advantages being
* No more static TagUtils * Coherent API for tags and other rendering tools
* Pluggable, extensible implementation
The best part is that the Velocity crew has already done all the foundation work. We just have to adopt and adapt :)
-Ted.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]