PrimeFaces 展示目前运行 PrimeFaces 4.0。仔细查看站点页脚中的版本信息。是在 PrimeFaces 4.0 中引入的,并且在 3.5RequestContext#openDialog()
中确实不存在。因此,此编译错误表明您使用的是旧版本,例如 3.5。在该版本中,您应该在 JavaScript 变量上调用该函数,该变量引用您可以通过属性指定的对话框。show()
widgetVar
例如纯粹在视图中:
<h:form>
<p:commandButton ... oncomplete="dialogWidget.show()" />
</h:form>
<p:dialog widgetVar="dialogWidget" ...>
...
</p:dialog>
或者,RequestContext#execute()
如果您绝对需要:
<h:form>
<p:commandButton ... action="#{bean.openDialog}" />
</h:form>
<p:dialog widgetVar="dialogWidget" ...>
...
</p:dialog>
和
public void openDialog() {
// ...
RequestContext.getCurrentInstance().execute("dialogWidget.show()");
}