The renderer class of a standard JSF component is implementation specific (Mojarra and MyFaces have each its own implementation) and is registered as <renderer>
in the implementation-specific faces-config.xml
(or an artifact of it).
To find it out, you basically need to know the component family and renderer type first, so that you can lookup the renderer class in the implementation-specific faces-config.xml
file youself.
Your starting point is the javax.faces.component.html
package summary. The <h:selectOneRadio>
is represented by the HtmlSelectOneRadio
component class. The introductory text of its javadoc says:
By default, the rendererType property must be set to "javax.faces.Radio
".
There is the renderer type.
The component family is specified as COMPONENT_FAMILY
constant under "Fields inherited from UISelectOne
" section of the very same javadoc. Click through to "Constant field values":
public static final java.lang.String
COMPONENT_FAMILY
"javax.faces.SelectOne
"
There is the component family.
Now, we should look in the implementation-specific faces-config.xml
file (or an artifact of it). Its location/name is unfortunately nowhere documented, but I can tell that in case of Mojarra it is the com/sun/faces/jsf-ri-runtime.xml
file in the implementation JAR file (you can extract JAR files with a zip tool). Open it and look for a <renderer>
entry matching the component family javax.faces.SelectOne
and renderer type javax.faces.Radio
:
<renderer>
<component-family>javax.faces.SelectOne</component-family>
<renderer-type>javax.faces.Radio</renderer-type>
<renderer-class>
com.sun.faces.renderkit.html_basic.RadioRenderer
</renderer-class>
</renderer>
Finally there is it: the com.sun.faces.renderkit.html_basic.RadioRenderer
.
Please note that extending exactly that class tight couples your custom renderer to the specific JSF implementation. Your renderer would not be reuseable on a different implementation such as MyFaces. To be implementation independent, you'd need to write the entire renderer yourself which extends javax.faces.renderer.Renderer
.
See also:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…