The performance question is a good one, but I thought I'd throw
something else into the discussion... I've thought about creating
something like this a number of times, as a way to make components more
flexible for the user.
When a component has more complex rendering, I often find I'd like to be
able to tweak the generated HTML in ways that simply aren't possible
without replacing the renderer. If the renderer was driven by a template
*and* there was a supported mechanism for specifying a custom template
(on a per-component-use basis or even just on a per-application basis),
this would be much easier.
On the other hand, the potential for people breaking the component by
changing the render template in unexpected ways is a little unsettling...
L.
Adam Winer wrote:
When I've thought of this, I've always imagined that
really complex renderers would end up requiring
Java code, and that really simple renderers, well,
aren't that hard to write in the first place, and would be
much slower when written that way. At that point,
I gave up and worked on things I was sure would work. :)
Templating a la Facelets has seemed like a pretty
good middle ground for assembling on-the-fly
components.
That said, I'd be absolutely thrilled to proven wrong!
So I guess two questions:
- Have you had a chance to benchmark the Freemarker-coded
outputText against the one in MyFaces?
- Any chance of tackling a complex component so we could
see what it looks like?
-- Adam
On 6/28/07, Jurgen Lust <[EMAIL PROTECTED]> wrote:
Hi,
I think most people will agree that writing Renderers for JSF components
using the standard tools, i.e. ResponseWriter.startElement and
ResponseWriter.writeAttribute etc., is not very straightforward or
productive, especially when creating complex components. If you take a
look at org.apache.myfaces.custom.schedule.ScheduleDetailedDayRenderer,
you'll know what I mean :)
One of the great things about Dojo is that you can create templates for
your components. Inspired by this, I tried to do something similar for
JSF renderers, using Freemarker. I put it in the sandbox, and wrote a
replacement HtmlOutputTextRenderer based on it. I know the outputText is
a bad example for this, but for complex stuff, this could be really
useful.
What do you think?
Jurgen