velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jason.Br...@cox.com>
Subject Include directive behavior
Date Wed, 17 Nov 2004 14:26:25 GMT
Aye, here's the rub:
If I have the following in my application's config file:
directive.include.output.errormsg.start = ***ERROR:
directive.include.output.errormsg.end = *****

I load those properties into Velocity when initializing, my
understanding is that any errors with the arguments for the Include
directive should be written to the output stream.
However, this is not occurring in cases where the argument references a
file that does not exist.  Instead a ResourceNotFoundException is
thrown, whether you define the start and end properties or not.
This could be by design, but I wanted to make sure.

I'm using velocity 1.3.1 but 1.4 does the same.

In Include.java, the render() function makes a call to renderOutput().
If renderOutput() returns false, then render() calls
outputErrorToStream().
However, renderOutput() will throw a ResourceNotFoundException if the
Included file does not exist (the exception is caught in renderOutput,
but thrown again).
This exception is not handled by render(), and so the exception gets
passed up the call stack without outputErrorToStream() ever being
called.

So my first question is:  is this a bug, or is there a reason to not
allow writing an error to the output stream in this case?

Question 2:  I can modify the Include directive, but is there a way to
configure Velocity at runtime to use the custom directive, so that I can
continue using an unmodified velocity jar?
I'm using setProperty() to override velocity.properties with values that
are in my application's config, but I can't see a way to do that to
override what's in directive.properties.

Thanks,
Jason


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


Mime
View raw message