[英]JSF2: ui:include: Component ID must be unique
Basic question: 基本问题:
Including a page, that contains a component with component id, multiple times cannot be done. 包含一个页面,其中包含具有组件ID的组件,多次无法完成。 But how can i have a reference to that component iside that included page?
但是,我如何能够在包含页面的情况下引用该组件?
Example: 例:
included.xhtml included.xhtml
....
<h:form id="foo"/>
....
<!-- here i need reference to foo component of this page -->
index.xhtml 的index.xhtml
....
<ui:include src="included.xhtml" />
<ui:include src="included.xhtml" />
<ui:include src="included.xhtml" />
With ui:include
the id will be duplicated. 使用
ui:include
id将被复制。
You can pass a parameter to your included xhtml and prefix your id 您可以将参数传递给包含的xhtml并为您的ID添加前缀
<ui:include src="included.xhtml">
<ui:param name="idPrefix" value="myFormIdPrefix"/>
</ui:include>
In the included xhtml 在包含的xhtml中
<h:form id="#{idPrefix}_foo"/>
Now it is possible to reference the id as #{idPrefix}_foo
现在可以将id引用为
#{idPrefix}_foo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.