You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "tlecavel.ml" <tl...@laposte.net> on 2006/05/18 17:08:54 UTC
Batch a template?
Hello,
The process to evaluate a template is quite long and take many
ressources on the CPU. Is it possible to "batch" a template
with a set of different context to save time?
I explain: at this time a have a function that do something like:
StringBuffer buffer = new StringBuffer();
Velocity.init();
VelocityContext context = new VelocityContext(voContext);
StringWriter w = new StringWriter();
Velocity.evaluate(context, w,
getConfig().getProperty("velocity.logFile"),
template);
buffer.append(w);
return buffer;
And this block is called about a hundred of times where only
voContext is modified. Is there a way to evaluate just once
the template and then give Velocity a list of context to treat?
Thanks for your help.
-- Thomas.
Accédez au courrier électronique de La Poste : www.laposte.net ;
3615 LAPOSTENET (0,34 /mn) ; tél : 08 92 68 13 50 (0,34/mn)
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Batch a template?
Posted by Nathan Bubna <nb...@gmail.com>.
Don't use the evaluate() method. That's a shortcut method that is
more expensive than the standard methods. You just need to use
Velocity in the standard way:
http://jakarta.apache.org/velocity/docs/developer-guide.html#The%20Fundamental%20Pattern
Then the template can be parsed and cached for immediate re-use with
different contexts.
On 5/18/06, tlecavel.ml <tl...@laposte.net> wrote:
> Hello,
>
> The process to evaluate a template is quite long and take many
> ressources on the CPU. Is it possible to "batch" a template
> with a set of different context to save time?
>
> I explain: at this time a have a function that do something like:
>
> StringBuffer buffer = new StringBuffer();
>
> Velocity.init();
> VelocityContext context = new VelocityContext(voContext);
>
> StringWriter w = new StringWriter();
>
> Velocity.evaluate(context, w,
> getConfig().getProperty("velocity.logFile"),
> template);
>
> buffer.append(w);
> return buffer;
>
> And this block is called about a hundred of times where only
> voContext is modified. Is there a way to evaluate just once
> the template and then give Velocity a list of context to treat?
>
> Thanks for your help.
>
> -- Thomas.
>
> Accédez au courrier électronique de La Poste : www.laposte.net ;
> 3615 LAPOSTENET (0,34 €/mn) ; tél : 08 92 68 13 50 (0,34€/mn)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org