That's a bit strange. Let me step through the test code and see what I find.

Have you changed the max size of the cache?

WILL

On 5/4/07, Bensman, Jeff [EESUS Non J&J] <[EMAIL PROTECTED]> wrote:

I've got the Velocity 1.5 engine integrated into my application's code and
everything seemed to be going great.  But then, I noticed that template
caching is only _kinda_ working.

I've stepped through the Velocity source code to verify that my template
object is correctly reloading when modified (I'm using
FileResourceLoader).
By verify, I mean that I can see that the ResourceLoader's isCachingOn()
is
correctly returning true and the class's modificationCheckInterval
reflects
my property setting (10 seconds).  And if I...

- call Velocity.getTemplate(String name)
- run a merge( Context context, Writer writer) on the returned template
- go out to the file system and edit the template file (after waiting 10
seconds)
- and then re-run the Velocity.getTemplate()

...I see that the Template object I get from getTemplate() the second
time,
reflects the file system change I made (Yeah!), because its data property
is
holding my new stuff.  BUT, when I call merge on it, the StringWriter I
get
back reflects the old state of the template, before my change!

Here's my code:

public static String buildView(String templateName, Map templateData )
throws Exception {
    VelocityContext velocityContext = new VelocityContext(templateData);
    Template velocityTemplate = Velocity.getTemplate(templateName);
    StringWriter stringWriter = new StringWriter();
    velocityTemplate.merge( velocityContext, stringWriter );
    return stringWriter.toString();
}

What am I missing?  I went back to Velocity 1.4 to make sure it wasn't
some
new bug in 1.5, but 1.4 behaves the same way.

Thanks for any help,

Jeff




--
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com

Reply via email to