You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jeff Harrington <je...@MIT.EDU> on 2003/07/21 15:03:01 UTC

Handle to the context from the template

hi,
  I'm using generic tools RenderTool.eval() (works great) from my template, 
but I was wondering is there a predefined  variable I can use to get a 
handle to the context in the template?
The eval signature looks like eval($context, string to be parsed), do I 
really need to do something like this from the servlet:

context.put("context", context);

in order to get a handle to the context for the eval call as in:

$render.eval($context, $string)

thanks,
Jeff


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Handle to the context from the template

Posted by Nathan Bubna <na...@esha.com>.
Jeff Harrington said:
>   I'm using generic tools RenderTool.eval() (works great) from my template,
> but I was wondering is there a predefined  variable I can use to get a
> handle to the context in the template?

nope.  you'll need to put it in there yourself.

> The eval signature looks like eval($context, string to be parsed), do I
> really need to do something like this from the servlet:
>
> context.put("context", context);
>
> in order to get a handle to the context for the eval call as in:
>
> $render.eval($context, $string)

if you are using the VelocityViewServlet, you should be able to just use the
ViewRenderTool and do

$render.eval($string)

the toolbox system makes it easy for the ViewRenderTool to implement the
ViewTool interface and get access to the context automatically.

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Handle to the context from the template

Posted by Ch...@dlr.de.
For this purpose I recomend either:
a) in your code (application or servlet) do the
    context.put("context", context);
or
b) creating a minimal #addContext()...#end directive to allow
    context inspection for chained contexts. This can be easily
    achieved using the #foreach directive or the whiteboard contribution
    of the #local directive as coding examples.
    (please contribute such an implementation back to this list).

Cheers,
Christoph

Jeff Harrington wrote:
> hi,
>  I'm using generic tools RenderTool.eval() (works great) from my 
> template, but I was wondering is there a predefined  variable I can use 
> to get a handle to the context in the template?
> The eval signature looks like eval($context, string to be parsed), do I 
> really need to do something like this from the servlet:
> 
> context.put("context", context);
> 
> in order to get a handle to the context for the eval call as in:
> 
> $render.eval($context, $string)
> 
> thanks,
> Jeff
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 

-- 
:) Christoph Reck


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org