velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <>
Subject Re: Streaming from the middle of a template?
Date Tue, 05 Apr 2005 17:10:15 GMT
Hi Evan,

> Here's what I'm doing: I've written a reusable html-control model for
> creating html components within the struts framework using velocity. These
> components use velocity themselves to render their content. These controls
> may also themselves contain other sub-controls, and so on.  It seems
> ineffecient for me for each of these sub-controls, to have to create a
> single large string and return it to its parent control to render it. I
> would rather pass a writer down through the execution hierarchy having each
> subcontrol add its output to the parents writer, thus using a single writer
> to achieve the total output, instead of a segmented writer.toString ->
> writer.toString -> writer.toString sort of process.
> Does that make more sense?

If all the components uses Velocity to render the content, you must be
using Template#merge or Velocity(Engine)#mergeTemplate or
Velocity(Engine)#evaluate in each of your components, correct?  If so,
you can just put the Writer in the Context before rendering.
    context.put("writer", writer)
And in the template,

Best regards,
-- Shinobu

Shinobu Kawai <>

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

View raw message