is m_velocityContextMap a Map or a Context?  if it is a Map, then
VelocityContext uses that as its inner storage for storing/retrieving
variables.   if it is a Context, then VelocityContext will "chain" it,
meaning that variables can be retrieved from the chained context when
they are not found in the inner storage and calls to put() (which
happens when you do #set( $animal = "Monkey" )) are only local to the
inner storage and do not affect the inner context

so, i'm guessing that m_velocityContextMap is a Map.   If you turn it
into a context first:

VelocityContext innerContext = new VelocityContext(m_velocityContextMap);

and then use that to create a new context for each call to evaluate:

VelocityContext context = new VelocityContext(innerContext);

then that should do what you expect.

On 4/4/07, Ashish Parikh <[EMAIL PROTECTED]> wrote:

I am creating new VelocityContext object on evey call to evaluate.

VelocityContext context=new VelocityContext(m_velocityContextMap);

However the m_velocityContextMap that i am passing into VelocityContext
constructor is a static variable.


Nathan Bubna wrote:
>
> Use a different context for different calls to evaluate().
>
> On 4/4/07, Ashish Parikh <[EMAIL PROTECTED]> wrote:
>>
>> Hello,
>>
>> Velocity in caching the variables created in a velocity template.
>> E.g.
>> 1) In template aTemp.vm, I have
>> #set ($animal = "Monkey")
>>
>> The aTemp.vm has been evaluated by Velocity.evaluate().
>>
>> 2) In bTemp.vm, if i do
>> $animal, It prints out Monkey which was sent in aTemp.vm.
>>
>> I am using singleton velocity and doing Velocity.init just once on the
>> startup of the webapplication.
>>
>> Anyways to avoid this??
>>
>> Thanks in advance
>>
>>
>> --
>> View this message in context:
>> 
http://www.nabble.com/Velocity-template-variables-caching-issue-tf3528978.html#a9848089
>> Sent from the Velocity - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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]
>
>
>

--
View this message in context: 
http://www.nabble.com/Velocity-template-variables-caching-issue-tf3528978.html#a9848152
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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]

Reply via email to