>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."

Now, an alternative implementation would be to do everything in a "pull"
model, which would get around the multiple copy problem. But I dislike this
because it requires the "outer" template writer to have full knowledge of
the contents of each of the sections inside. I'd rather just have the outer
section writer be able to use some kind of generic reference (like
$inner_content above) and have the system be able to deal with what exactly
is in that "inner" section (and it's not in Java code, there is a registry
to tell the system this information). 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:

<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
#set ($col = 0)
#foreach ( $column in $portlets )
...
#end
</tr></table>

which is essentially what I want to do.

Thanks for your consideration.

<>< gary

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Daniel Rall
Sent: Thursday, February 21, 2002 12:29 PM
To: Turbine Users List
Subject: Re: VM Templates vs JSP, How does everyone find VM speed


"Gary Bisaga" <[EMAIL PROTECTED]> writes:

> I don't know, but I have been wondering about the same issue. In
particular:
> in our application the displayed web page is made up of nested "sections",
> each of which has its own template. Sort of like jetspeed does it, with
the
> portlets, controls, and controllers.
>
> This means that there's an awful lot of string copying going on, as you
> collect the results from the innermost template, include that in the
> next-outer template, and so on. One specific thing I was wondering is
> whether there is any support for using a scatter/gather kind of operation
in
> Velocity, where you have a structure like this:
>
>   public class ScatterGatherObject {
>     // Each one of the objects in this list can either be (a) a String or
>     // (b) another ScatterGatherObject.
>     ArrayList subObjects;
>     public String toString () { ... }
>   }
>
> Velocity could, at each template stage, produce one of these objects
instead
> of a String. The values you put in the context could be either Strings or
> ScatterGatherObjects; in the latter case, the new ScatterGatherObject
would
> simply get a reference to the old one. Finally, at the end of processing,
> the toString method would go depth-first through all the
> ScatterGatherObjects and concatenate all the Strings in one big
> StringBuffer. It seems to me that this could potentially eliminate a hugh
> amount of string copying.
>
> Any thoughts?

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


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

Reply via email to