velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Include directive behavior
Date Wed, 17 Nov 2004 16:18:55 GMT

Thank you for the reply.  I'll file an issue and see what the developers
say.  Meanwhile, I did get a workaround working with the userdirective.
One thing I forgot to mention was that I intended to override the system
"include" directive with my userdirective, and the documentation did not
mention if this was possible.
However, I found the answer which I'll submit to the list for the
benefit of the archives. :-)

To set a userdirective at runtime, use:
Before calling VelocityEngine.init().

In order to override a system directive, make myDirectiveClass.getName()
return "include" (or the name of whatever system directive you're

Now, in your templates, when you call #include, it will execute your own
directive instead of Velocity's Include directive.

Hi Jason,

> 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?
I don't know about this.  Maybe it should be discussed in the developer
## Or you can just file an issue and see what happens.  B)

> 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
> continue using an unmodified velocity jar?
> I'm using setProperty() to override with values
> are in my application's config, but I can't see a way to do that to
> override what's in
Try userdirective.

Best regards,
-- Shinobu Kawai

Shinobu Kawai <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message