> 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,
>     $component.render($writer)


Right right, exactly, but how to I get the writer?

How do I get the writer from the parent velocity template such that I can
pass it to the child templates and have there output slip right into the
output of the parent?


-Evan





-----Original Message-----
From: Shinobu Kawai [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 05, 2005 1:10 PM
To: Velocity Users List
Subject: Re: Streaming from the middle of a template?

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,
    $component.render($writer)

Best regards,
-- Shinobu

--
Shinobu Kawai <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to