【发布时间】:2015-02-06 14:14:57
【问题描述】:
我尝试使用 <p:overlayPanel> 作为 PrimeFaces 展示示例 (http://www.primefaces.org/showcase/ui/overlay/overlayPanel.xhtml) 中所述的小部件。
我构建了一个简单的应用程序,但在页面加载时它直接导致 JavaScript 错误 TypeError: f is undefined 在“/javax.faces.resource/primefaces.js.xhtml?ln=primefaces&v=5.1”中的第 3 列第 1457 行
xhtml正文代码为:
<h:form id="form">
<p:commandButton update=":form:infoPanel" oncomplete="PF('testOverlayPanel').show('#{component.clientId}')" value="Test"/>
<p:overlayPanel widgetVar="testOverlayPanel" dismissable="false" showCloseIcon="true">
<p:outputPanel id="infoPanel" style="text-align:center;">
Hello OverlayPanel!
</p:outputPanel>
</p:overlayPanel>
</h:form>
当我移除 overlayPanel 后,JavaScript 错误消失了。
当我按下命令按钮时,又出现两个 JavaScript 错误:
- NetworkError: 403 Forbidden - https://localhost:8443/test/index.xhtml
- TypeError: PF(...) 未定义
我将 PrimeFaces 5.1 与 JSF 2.2.8 一起使用
【问题讨论】:
-
你有 h:head、h:body 等吗?
-
@Jaqen: 可能,否则
primefaces.js不会首先加载。 -
是的,但谁知道呢:-)
-
正确。这很奇怪:当我将
id="cmdBtnId"添加到命令按钮并将for="cmdBtnId"添加到overlayPanel 时,它工作正常。但我不想将 overlayPanel 绑定到一个按钮,它应该绑定到按钮列表,就像 PrimeFaces 的展示示例一样。
标签: jsf-2 primefaces