velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Cohen <sco...@javactivity.org>
Subject Template lose track of variable?
Date Wed, 21 Jan 2009 20:49:03 GMT
Velocity has been a rock-solid winner for our company's use which has 
been in effect for less than a month.

Now, however, I see a glitch that I can't explain:

Our templates are all very simple.  Most use no macros, just straight 
variables which are relatively simple POJOs for the most part and the 
template page we are discussing indeed uses no macros, just text and a 
couple of variables.

This page has template text  something like this:

Your telephone number is <b>$tn.USFormattedTn</b>


where tn is an object of class TelephoneNumber
and class TelephoneNumber has a method String getUSFormattedTn().

We had a complaint of one instance in which this rendered as

Your telephone number is $tn.USFormattedTn
instead of
Your telephone number is 1-203-999-9999
which is how it should have rendered.

I can see from my logs that the context passed to this template in this 
instance had the tn variable and that it wasn't found by Velocity:

2009-01-20 16:58:15,902 [robo/AIM:jrelay/2701] TRACE 
velocity.VelociWrapper - {tn=203-999-9999, lang=English}
2009-01-20 16:58:15,910 [robo/AIM:jrelay/2701] DEBUG Velocity - 
ResourceManager : found /resources/en_US/number/ExitComplete.vm with 
loader org.apache.velocity.tools.view.servlet.WebappLoader
2009-01-20 16:58:15,911 [robo/AIM:jrelay/2701] DEBUG Velocity - Null 
reference [template '/resources/en_US/number/ExitComplete.vm', line 6, 
column 56] : $tn.USFormattedTn cannot be resolved.

The first log line is my wrapper which shows that tn is in the context 
passed to velocity
The second log line shows that my template was found.
The third shows that Velocity could not resolve my reference

I can find many other instances in my logs where the USFormattedTn 
property is successfully rendered on other
velocity pages and I have never seen this behavior before.  I have been 
all over my code verifying that the tn object was placed in the context, 
that nothing removed it from the context, checked all capitalization, 
etc. and I cannot see that I have done anything wrong to produce this 
result.

What might account for this glitch?

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


Mime
View raw message