如何在jsf中为自定义组件添加自定义属性?
我正在JSF中的taglib.xml中创建如下代码所示的自定义组件如何在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
<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");