基本问题:
包含一个页面,其中包含具有组件ID的组件,多次无法完成。但是,如何在包括页面的那个组件中引用该组件?
示例:
included.xhtml
....
<h:form id="foo"/>
....
<!-- here i need reference to foo component of this page -->
的index.xhtml
....
<ui:include src="included.xhtml" />
<ui:include src="included.xhtml" />
<ui:include src="included.xhtml" />
答案 0 :(得分:8)
使用ui:include
时,ID将重复。
您可以将参数传递给附带的xhtml并为您的ID添加前缀
<ui:include src="included.xhtml">
<ui:param name="idPrefix" value="myFormIdPrefix"/>
</ui:include>
包含xhtml
<h:form id="#{idPrefix}_foo"/>
现在可以将ID引用为#{idPrefix}_foo