tiles-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Petrelli <antonio.petre...@gmail.com>
Subject Re: [tiles3] More subprojects to achieve "universality"
Date Sun, 29 Aug 2010 18:56:04 GMT
2010/8/29 Nathan Bubna <nbubna@gmail.com>:
> Sounds reasonable.  I'm not all that familiar with the details of the
> code you describe, so it's hard for me to comment intelligently, but i
> trust your judgment.

I hope to be clearer with an example for AttributeRenderer, near to
your experience with Velocity ;-)

TemplateAttributeRenderer renders a template using the normal
RequestDispatcher. This is useful for all templates that can be
invoked through a servlet (e.g. JSP pages).

VelocityAttributeRenderer does not use a servlet explicitly, but uses
a private instance of VelocityView that is invoked this way:

ServletRequest servletRequest = ServletUtil.getServletRequest(request);
// then get a context
Context context = velocityView.createContext(servletRequest
        .getRequest(), servletRequest.getResponse());

// get the template
Template template = velocityView.getTemplate((String) value);

// merge the template and context into the writer
velocityView.merge(template, context, request.getWriter());

A similar implementation is for Freemarker, but uses a private
instance of a servlet class.

In all of these cases, the invocation is made through the render environment:

void render(Attribute attribute, Request request) throws IOException;

A similar approach is applied for evaluators.

Thanks for the feedback

View raw message