myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Werner Punz <>
Subject Re: template based renderer (using Jakarta Velocity)
Date Wed, 06 Jul 2005 17:59:05 GMT
Matthias Wessendorf wrote:
> Hi all.
> Last night I played a bit with Velocity templates to render JSF UI
> components. Here is a document that contains some infos regarding
> this.
> Note: it is a first version. Not complete, but I'll look deeper into this.
> Here it goes:
> Perhaps it contains useful informations for you...
Hallo Matthias

Having used velocity myself for two big projects I know the merits
and downsides of it pretty well, but generally I love it.

To your work, neat stuff.... btw.. here is a proposal for something more 
also that might ease renderer creation significantly because
you can code the renderers in velocity instead of using java....

What you simply have to do is to push the component into the context
as control variable and then you can access all the binding
vars from the velocity template scope

code for something velocity related would look like this:

#if(${component.visible}) {
	<H1>control is visible</H1>
} else {
	<H1>control is not visible</H1>	

now compare that to a code which is basically hardcoded into the renderer...

the only thing you probably have to do in your renderer is:

ctx.put("component", component);

since the context is sort of a variable stack you will be able to access 
the component object and all of its attributes.

The main benefits to such an approach compared to the classical one is, 
that basically once you have a running mockup in the target document 
format you just have to rip it out and replace your mockup values from 
the original code with the values from the control which are delivered 
by the tags.

There is a downside to that approach however, it will slow things down a 
little bit renderingwise, so probably caching the templates on velocity 
level or jsf level in a production system to speed things up again, 
might be a good idea. Anyway one way or the other, you will get a speed hit.

View raw message