On Fri, Apr 4, 2008 at 11:23 AM, Charles Harvey III <[EMAIL PROTECTED]> wrote:
>
>
> > That method returns a org.apache.velocity.context.Context.
> >
> > --------------------------------------------------------------------------
> > protected Context createVelocityContext(
> > Map model, HttpServletRequest request, HttpServletResponse response)
> throws Exception {
> > // Create a ChainedContext instance.
> > ChainedContext velocityContext = new ChainedContext(
> > new VelocityContext(model), getVelocityEngine(), request,
> response, getServletContext());
> > // Load a Velocity Tools toolbox, if necessary.
> > if (getToolboxConfigLocation() != null) {
> > ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
> > getServletContext(), getToolboxConfigLocation());
> > Map toolboxContext = toolboxManager.getToolbox(velocityContext);
> > velocityContext.setToolbox(toolboxContext);
> > }
> > return velocityContext;
> > }
> > --------------------------------------------------------------------------
> >
> Taking a look at the above, can I just do this instead?
>
>
> protected Context createVelocityContext( Map model, HttpServletRequest
> request,
> HttpServletResponse response ) throws Exception
> {
> ViewToolContext velocityContext = new ViewToolContext(
> getVelocityEngine(),
> request, response, getServletContext() );
> return velocityContext;
> }
>
> Looking at the "ViewToolContext" it seems to create the toolbox
> auto-magically.
> Is that so? Or am I missing something?
though i essentially answered this question in my last email, i'll add
some info here for general education:
no, the ViewToolContext doesn't auto-magically create toolboxes. it
only finds them auto-magically. in order to make tools more easily
accessible, the actual Toolboxes are put into the
request/session/servletContext attributes after being created by the
ToolboxFactory. the ViewToolContext just knows how to find them
there.
this is so that apps don't have to use a Context implementation at all
to get access to tools, as some people wanted to use tools outside of
templates. :) it also gives frameworks some extra flexibility if they
want.
> Thanks again.
>
>
>
>
> Charlie
>
>
> ---------------------------------------------------------------------
> 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]