I use the following strategy.

Create a context that will be used for all templates:
   VelocityContext baseCtx=new VelocityContext();
   baseCtx.put("something",someObject);
     ...

Then for each template rendering:
   VelocityContext ctx=new VelocityContext(baseCtx);
    ctx.put("this",anotherObject);
    ....

Then use ctx to actually render the template.  Put the ctx creation
and rendering in a separate method so the garbage collector will treat
it as a temporary object in your program.

No need to "flush".  You can remove individual objects from the
context and get a list of object keys, etc.,  but it seems that would
be less efficient than the above strategy.

Barbara Baughman
X2157

On Thu, 9 Feb 2006, Anagha wrote:

> Hi,
> I'm writing the utility class which has different methods for different
> templates all of which share a common context.
> At the start of each method I  want to ensure that context populated
> previously by any method is flushed.
> This is as good as flushing of all entries in the context.
> I did not see any vel- API for this.
> Any pointers?
> Any help is welcome.
> --
> Thanks & Regards,
> Anagha
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to