In JSF Tip #32 - Override a JSF Renderer and JSF Tip #34 - Override a JSF Renderer and create a new tag for it we have described ways to override a renderer.
Well, would you believe there is yet another way?
It is as simple as adding an f:attribute tag as a child of the component you want to change the renderer for.
<h:panelGroup> <f:attribute name="rendererType" value="MyRenderer"/> </h:panelGroup>
And then make sure you set it to the right componentFamily, in this case for an h:panelGroup the component family is "javax.faces.Panel" and that the value of the f:attribute matches up with the rendererType set for your renderer.
@FacesRenderer(componentFamily = "javax.faces.Panel", rendererType = "MyRenderer") public class MyRenderer extends Renderer { @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { context.getResponseWriter().write("DEMO DEMO DEMO"); } }
Posted October 16, 2014