In the development of a library based on Trinidad, I need to have some hooks
in the renderer to improve performance. Specifically, I need to setup a
context and strip down a context for a component. Right now,
CoreRenderer.encodeEnd(FacesContext, UIComponent) is final, so I cannot
extend that method and the methods it calls I cannot reliably use (see
below).

What I propose is:

new methods on CoreRenderer:
protected void startComponent(FacesContext context, RenderingContext
context, UIComponent component, FacesBean bean) {}
protected void endComponent(FacesContext context, RenderingContext context,
UIComponent component, FacesBean bean) {}

These methods would be invoked from within
"CoreRenderer.encodeBegin(FacesContext,
UIComponent)" and "CoreRenderer.encodeEnd(FacesContext, UIComponent)"
respectively.

The benefit is that someone creating a component framework on top or
Trinidad can extend the ability to setup and tear down settings when a
component is being rendered. In my case, I need to extend the skinning code
in a framework to enable certain functionality on a per-component basis from
within the skin and have this functionality global to all our renderers.

You may ask "why not just extend encodeAll?". Well the problem is that I
have no idea when the child class will call this. For example:

  protected void encodeAll(FacesContext context, RenderingContext arc,
UIComponent component, FacesBean bean) throws IOException
  {
    ... code
    super.encodeAll(context, arc, component, bean);
    ... code
  }

As you can see, encodeAll doesn't give me the ability to have a hook from
the renderer class level for when the component starts and ends. It doesn't
make good OO code to have to manually code it in every one of our renderers.

I also see the reason in having the methods final, so would prefer the hooks
over removing the final keywords from encodeBegin and encodeEnd.

Any objections to adding these 2 methods/hooks?

If ppl. don't mind to respond quickly, I'll make the change if I get some
quick positive feedback and no negative feedback. This is a fairly high
priority feature that I need this for and cannot afford the 3 day vote
period.

Thank you,
Andrew

Reply via email to