我阅读了许多有关此问题的帖子,但找不到解决方案。
我的 JSF 开头有一个带有命令按钮的表单,它应该打开对话框。Dialog 在 Dialog 内部有一个表单,以及属性 modal 和 appendToBody。我的页面只是重新加载自身并且不弹出对话框。
<ui:composition template="../templates/site.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:sec="http://www.springframework.org/security/tags">
<ui:define name="content">
<h:form>
<p:commandButton value="Button" id="myButton" onclick="myDialog.show()" />
</h:form>
<p:dialog id="dialog" widgetVar="myDialog"
header="Dialog" closable="true" resizable="false" width="600"
height="350" modal="true" appendToBody="true" dynamic="true">
<h:form>
...
</h:form>
</p:dialog>
</ui:define>
</ui:composition>