velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Petrelli <>
Subject Re: [tools-2.0] How to access Writer in tool
Date Fri, 27 Feb 2009 13:22:35 GMT
2009/2/27 Antonio Petrelli <>:
> 2009/2/26 Nathan Bubna <>:
>> On Thu, Feb 26, 2009 at 1:41 PM, Antonio Petrelli
>> <> wrote:
>>> Hi all
>>> Is there a way to access the writer that is used to write in the
>>> response, from a request-scoped tool?
>> In Velocity 1.6, we introduced the
>> org.apache.velocity.runtime.Renderable interface, which has a "boolean
>> execute(context, writer)" method.  If, when rendering a reference,
>> Velocity comes across a Renderable, it calls that method instead of
>> calling toString() and writing that value.  but even if you do
>> implement Renderable, please consider having your toString() be
>> functional (e.g. passing a StringWriter and null context to
>> execute(...)).
> Thanks a lot, I will try the Renderable interface.

Tried and it worked :-)
Instead of executing the rendering code directly in the called method,
I create an instance of an anonymous Renderable that is executed when
Just if you want to take a look:

See the "execute" method.

Thanks again!

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

View raw message