2009/2/27 Antonio Petrelli <antonio.petre...@gmail.com>:
> 2009/2/26 Nathan Bubna <nbu...@gmail.com>:
>> On Thu, Feb 26, 2009 at 1:41 PM, Antonio Petrelli
>> <antonio.petre...@gmail.com> 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
needed.
Just if you want to take a look:
http://svn.eu.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertDefinitionVModel.java?view=markup

See the "execute" method.

Thanks again!
Antonio

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

Reply via email to