"Gary Bisaga" <[EMAIL PROTECTED]> writes: >>Velocity streams data directly using the Writer it was provided with. >>One the AST is built, static content needs no further memory allocated >>for it. > > I'm pretty much a newbie to Turbine so I'm not sure whether this answers my > question. Perhaps it does; but in my understanding of how this all works, > say I am doing these operations: > > 1. First process the "inner" section's template (e.g. the Jetspeed portlet) > by calling mergeTemplate( String templateName, Context context, Writer > writer ). The Writer presumably is something like a CharacterArrayWriter. It > can't go directly out to the browser because in step 3 below I want to > include this content in the middle of the "outer" template's content. > > 2. Somehow get the data in the CharacterArrayWriter into the context. I > think this is necessary because I want to, in my "outer" section's template, > to refer to the inner section's data. The "outer" template would then look > something like this: > > <TABLE><TR><TD>$inner_content</TD></TR></TABLE> > > 3. This requires Velocity, on the second call to mergeTemplate, to convert > the data from each "inner" CharacterArrayWriter into a String so it can > stream it out to the "outer" Writer, which involves an extra copy of each > "inner" string value, which is what I am trying to avoid. These copies (I > believe) include what you refer to as "static content."
Using a buffer for the "body" content is something that's often done by Velocity users. However, it's a fairly inefficient usage of an efficient engine (especially if your application does not pool the buffers). A method which I've been tossing around to deal with this is to use a ReferenceInsertionEventHandler: http://jakarta.apache.org/velocity/developer-guide.html#EventCartridge%20and%20Event%20Handlers $inner_content has a handle to some sort of processing mechanism which is triggered (tested for using instanceof) by the ReferenceInsertionEventHandler configured for your EventCartridge. The triggered code writes to the same output stream which the Writer you passed to mergeTemplate() uses. > If I'm not mistaken (please correct me if I am wrong) this is > exactly what Jetspeed does: for example the multicolumn-customize.vm > template says: This is the Turbine User list, not the Jetspeed list. Please direct your Jetspeed questions to [EMAIL PROTECTED] - Daniel -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
