Jsf 自定义组件的组件类型名称是否需要唯一?

Jsf 自定义组件的组件类型名称是否需要唯一?,jsf,jsf-2.2,custom-component,Jsf,Jsf 2.2,Custom Component,我是从JSF2.2开始的自定义组件主题的新手 然而,我首先考虑的是JSF2.0 考虑一下这个片段: @FacesComponent(value = "components.WelcomeComponent1", createTag = true) public class WelcomeComponent extends UIComponentBase { } 注意value=“components.WelcomeComponent1” 在UI线框中引用它- <html xmlns="

我是从JSF2.2开始的自定义组件主题的新手

然而,我首先考虑的是
JSF2.0

考虑一下这个片段:

@FacesComponent(value = "components.WelcomeComponent1", createTag = true)
public class WelcomeComponent extends UIComponentBase {

}
注意
value=“components.WelcomeComponent1”

在UI线框中引用它-

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:t="http://xmlns.jcp.org/jsf/component">
    <h:head>
        <title></title>
    </h:head>
    <h:body>       
        <t:welcomeComponent value="Welcome" to="Rafael Nadal"/>
    </h:body>
</html>
注意
“components.WelcomeComponent”

WEB\u-INF中的taglib.xml

我确实明白-

警告:此页调用XML命名空间 用前缀t声明,但不声明 该命名空间存在标记库

显然,首选
taglib.xml
中声明的条目/标记

因此,组件类型名称在每种情况下都必须是唯一的。对吧?


我很清楚名称空间
http://xmlns.jcp.org/jsf/component
是在
JSF2.2
中引入的

简短回答是,它应该是唯一的。JSF将其视为自定义组件的名称(类似于
@ManagedBean
)。基本上,组件类型允许
Application
instance通过使用定义的组件类型和
createComponent()
方法创建
UIComponent
子类(您的和所有其他自定义组件)的新实例

@FacesComponent("components.WelcomeComponent")
public class WelcomeComponent extends UIComponentBase {
          // code goes here
}
    <namespace>http://atp.welcome.org/welcome</namespace>

    <tag>
        <tag-name>welcome</tag-name>
        <component>
            <component-type>components.WelcomeComponent</component-type>
        </component>

        <attribute>
            <name>id</name>
            <type>java.lang.String</type>
            <description>Component id</description>
            <required>false</required>
        </attribute>


    </tag>

</facelet-taglib>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:t="http://atp.welcome.org/welcome">
    <h:head>
        <title></title>
    </h:head>
    <h:body>
        <t:welcome value="Welcome" to=""/>        
    </h:body>
</html>
@FacesComponent("components.WelcomeComponent1")