【发布时间】:2012-05-04 10:56:00
【问题描述】:
我正在使用 JSF2 facelets。
我正在尝试使用<ui:composition> 和<ui:insert> 标签将一段代码从一个页面插入另一个页面。
我有页面 A,其中包含页面 B 中的代码。
<h:form id="formIdPageA">
...
<h:form id="formIdPageB">
问题似乎是表单 ID,因为我收到错误:
System error: Cannot find component with identifier ":formIdPageA:fileListId" in view.
这是从页面 B 插入到页面 A 的一段代码。这里可以看到 id:
<tr>
<td colspan="2">
<p:selectOneMenu id="locationId" value = "#{PFMultiFileSelectMgmtBean.selectedLocationId}">
<p:ajax update=":formIdPageA:fileListId" listener="#{PFMultiFileSelectMgmtBean.LocationChangeEvent}"/>
<f:selectItems value="#{PFJobMgmtBean.outputLocationList}"/>
</p:selectOneMenu>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
<p:selectManyCheckbox id="fileListId" value="PFMultiFileSelectMgmtBean.selectedFiles" layout="pageDirection">
<f:selectItems value="#{PFMultiFileSelectMgmtBean.fileNames}" />
</p:selectManyCheckbox>
</td>
</tr>
这就是我在页面 A 中插入它的方式:
<p:dialog id="basicDialog" header="Select Files" widgetVar="dlgMultiFileSelect" modal="true" height="500" width="500" resizable="false">
<ui:insert>
<ui:include src="/pageB.xhtml"/>
</ui:insert>
</p:dialog>
有谁知道是否可以包含这样的页面? <ui:composition> 是在正文标签之前还是在页面 B 之后?可以吗:
<body>
<f:view>
<h:form id="formIdPageB">
<ui:composition>...
?
好的,找到了:
问题是我使用了PrimeFaces组件<p:dialog>,并把它放在<h:form>之外和<body>之外的页面A中,像这样:
</h:form>
</f:view>
</body>
<p:dialog...>
<ui:include src="/pageB.xhtml"/>
</p:dialog>
这似乎是错误的。现在我将<p:dialog> 移到表单中,一切正常。
【问题讨论】:
标签: jsf primefaces facelets