How to findout component-family and renderer-type of a JSF component

前端 未结 1 821
甜味超标
甜味超标 2021-01-13 17:23

How can I findout the component-family and the (default) renderer-type of a JSF component?

These information are necessary when (overriding custom renderers) using

1条回答
  •  灰色年华
    2021-01-13 17:53

    Programmatically, you could find them out by just printing UIComponent#getFamily() and UIComponent#getRendererType().

    Documentary, you could find them out by just looking in the javadoc of the component implementation. For example, is represented by the HtmlInputText class. The renderer type can be found in the last paragraph of the introductory text of the javadoc:

    By default, the rendererType property must be set to "javax.faces.Text".

    The component family can be found by checking the value of COMPONENT_FAMILY constant field value (which is inherited from UIInput). Click your way through the Fields inherited from class javax.faces.component.UIInput - COMPONENT_FAMILY - Constant Field Values

    COMPONENT_FAMILY "javax.faces.Input"


    Unrelated to the concrete problem: you cannot override the default JSF renderers by the @FacesRenderer annotation. The default renderer would always get prededence. This is by design, see also issue 1748. You really need to register them explicitly as in the faces-config.xml the JSF 1.x way.

    
        
            javax.faces.Input
            javax.faces.Text
            com.example.CustomTextRenderer
        
    
    

    0 讨论(0)
提交回复
热议问题