You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Sam Joseph <ga...@yha.att.ne.jp> on 2002/12/27 13:03:26 UTC

VelocityServlet

Hi,

Apologies if this is something that has already been discussed, but I
was thinking about the design of the VelocityServlet, and I was thinking
wouldn't it be much more flexible if the developer had the freedom to
pass different kinds of output streams to the merge template operation.

I am thinking in the context of the Velocity 1.2 demo where the velocity
servlet is extended into a controller servlet, which passes off incoming
requests to objects that extend the command interface. The Commands
themselves take the HttpServletRequest and HttpServletResponse as
parameters (as well as a velocity context) and pass back a filled up
context along with a template name.

I was thinking that it would be much more flexible if I could pass the
Commands an output stream as well. What this would mean is that each
Command would actually write out the results of the merge to the output
stream (i.e. move it from velocity servlet to a base command object).

This would make it possible for commands to be more naturally nested. At
the moment I have lots of different templates and associated commands,
and I would love to be able to insert the results of merging some
templates into other templates.

Maybe in the ideal extreme this would involve something that associated
some a Command code with a template so that the
#parse("some_template.vm") command would parse the template and
instantiate some code in association with it. I guess this is sort of
what Turbine does, but I don't really want to take on the full Turbine
baggage.

At the moment I can perform separate merge operations within the code of
a Command object to try and insert one template (and associated code)
into another, but its not very neat.

Hmm, not sure I have explained myself very well.

I guess what I would like to see is something like the
VelocityServlet/ControllerServlet setup, but with the merging of
templates moved from the VelocityServlet to the ControllerServlets
Command objects. Thus one could call the Command object with a specific
outputstream and then be able to control whether the output was being
sent back over http by the VelocityServlet or sent somewhere else, such
as a debugging output, or just a StringWriter so that the results could
be inserted into another template ...

Any thoughts? Am I making any sense?

CHEERS> SAM


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>