Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在jsf中为自定义组件添加自定义属性?_Jsf_Jsf 2_Custom Component - Fatal编程技术网

如何在jsf中为自定义组件添加自定义属性?

如何在jsf中为自定义组件添加自定义属性?,jsf,jsf-2,custom-component,Jsf,Jsf 2,Custom Component,我正在JSF中的taglib.xml中创建如下代码所示的自定义组件 <tag-name>CustomComponent</tag-name> <component> <component-type>javax.faces.Input</component-type> </component> </tag> 在xhtml中呈现组件,如下所示 <h

我正在JSF中的taglib.xml中创建如下代码所示的自定义组件

     <tag-name>CustomComponent</tag-name>
   <component>
            <component-type>javax.faces.Input</component-type> 
    </component>
      </tag>
在xhtml中呈现组件,如下所示

<h:body bgcolor="white">
<cs:CustomComponent></cs:CustomComponent>       
            </h:body>
我想为这个组件添加自定义属性。如果给出了除我指定的参数以外的任何其他参数,则希望抛出警告。这在jsf中是可能的。

看这里

<tag>
<tag-name>training</tag-name>
<attribute>
    <name>style</name>
</attribute>
<attribute>
    <name>action</name>
    <method-signature>java.lang.String action()</method-signature>
</attribute>
<component>
    <component-type>training</component-type>
    <renderer-type>pl.spiid.app.spiidcharts.beans.training.Training</renderer-type>
</component>
在xhtml中,我可以使用,也可以在渲染器中检索:

    Map<String, Object> attrMap = component.getAttributes(); // to 
    String style = (String) attrMap.get("style");