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 2 JSF复合组件中不允许使用空id属性_Jsf 2_Composite Component - Fatal编程技术网

Jsf 2 JSF复合组件中不允许使用空id属性

Jsf 2 JSF复合组件中不允许使用空id属性,jsf-2,composite-component,Jsf 2,Composite Component,在为一组按钮使用下面提到的复合组件(按钮的计数可以是1到3)时,我面临一个问题“JSF中不允许使用空id属性”(我在Tomcat-7上使用Mojarra 2-0-8) 使用上述CC <Buttons:myButton txtHeader="Title" txtDescription="text1" txtAction="TextAction." button1Style="btnSave" buttonCount ="1" button1Id="

在为一组按钮使用下面提到的复合组件(按钮的计数可以是1到3)时,我面临一个问题“JSF中不允许使用空id属性”(我在Tomcat-7上使用Mojarra 2-0-8)


使用上述CC

<Buttons:myButton txtHeader="Title" txtDescription="text1"
                    txtAction="TextAction." button1Style="btnSave" buttonCount ="1" button1Id="btnSaveConf" button1Action="#{MyBean.save()}"></Buttons:myButton>

是否有更好的方法根据主页上的计数或任何类似输入动态生成按钮。
注意:-id、样式和操作的名称应该不同。

您不能在
id
属性中使用渲染时间EL。改为为给它一个固定的ID,并给组合本身一个ID。例如:

<buttons:myButton id="foo" ... />

在实施过程中

<h:commandButton id="button1" ... />
<h:commandButton id="button2" ... />
<h:commandButton id="button3" ... />

然后它们将成为
foo:button1
foo:button2
foo:button3
,其中
foo
部分在模板客户端中是可控的

如果您确实出于某种不明显的原因需要动态ID,那么您应该创建一个标记文件,而不是一个复合组件

<h:commandButton id="button1" ... />
<h:commandButton id="button2" ... />
<h:commandButton id="button3" ... />