如何查找JSF组件的组件族和渲染器类型 [英] How to findout component-family and renderer-type of a JSF component

查看:103
本文介绍了如何查找JSF组件的组件族和渲染器类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到JSF组件的组件族和(默认)渲染器类型?

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 the following annotation:

@FacesRenderer(componentFamily="",rendererType="")

我用Google搜索了,通过了JSF规范和Ed Burn的书,但是找不到我想要的东西.

I Googled, went throughed the JSF specification and Ed Burn's book, but couldn't find what I wanted.

推荐答案

以编程方式,您只需打印 UIComponent#getRendererType() .

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

纪录片,只需查看组件实现的javadoc,就可以找到它们.例如,<h:inputText> HtmlInputText 类.渲染器类型可以在javadoc介绍性文本的最后一段中找到:

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

默认情况下,rendererType属性必须设置为"javax.faces.Text".

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

可以通过检查COMPONENT_FAMILY常量字段值(从从类javax.faces.component.UIInput-COMPONENT_FAMILY继承的字段-常量字段值

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"


不相关与具体问题:不能通过@FacesRenderer批注覆盖默认的JSF渲染器.默认渲染器将始终具有优先权.这是设计使然,另请参见 issue 1748 .您确实需要使用faces-config.xml JSF 1.x方式将它们显式注册为<renderer>.


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 <renderer> in the faces-config.xml the JSF 1.x way.

<render-kit>
    <renderer>
        <component-family>javax.faces.Input</component-family>
        <renderer-type>javax.faces.Text</renderer-type>
        <renderer-class>com.example.CustomTextRenderer</renderer-class>
    </renderer>
</render-kit>

这篇关于如何查找JSF组件的组件族和渲染器类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆