Another approach would be to try and intercept stuff as each component
is rendered; for your purposes that's fine, yes? So how about this:
* Override the default RenderKit with a wrapper of your own.
* On each call to addRenderer(...), call:
super.addRenderer(new MyRendererWrapper(r));
so all the standard renderer objects have a custom wrapper around them
* Your custom wrapper then intercepts encodeBegin(), and potentially
updates the component's "rendered" state before delegating on to the
real renderer.
So if I understand you correctly, I should create a
public class MyKit extends HtmlRenderKitImpl that overrides addRenderer with something like
super(componentFamily, rendererType, new MyRenderer(renderer));
...
}
and then have a
public class MyRenderer extends Renderer {
private Render realRenderer;
public MyRenderer(Renderer realRenderer) {
this.realRenderer = realRenderer;
}
public void encodeBegin(FacesContext context, UIComponent component)
// Do magic with the component
realRenderer.encodeBegin(context, component);
}
}
Do I have to use super.calls for all other mehtods in Renderer also? Or did you mean I have to make a wrapper for each component class? And does that mean I would have to define them all in faces-config? What is the way that results in a) minimal number of custom classes, b) minimal number of additonal configuration in faces-config? Preferrably both ;-)
I also tried using Facelets for this as you suggested but was unsuccessful. Tried both a phaselistener and by extending all the mehtods in the facelet-viewhandler but was still unable to intercept :-/

