0

我阅读了许多有关此问题的帖子,但找不到解决方案。

我的 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>
4

1 回答 1

1

commandButton将您的代码更改为:

<p:commandButton value="Button" type="button" id="myButton" onclick="myDialog.show()"/>

这将创建一个普通的按钮(它只调用 JavaScript)并且不对服务器执行任何 AJAX 或非 AJAX 请求。按钮的默认类型是submit

于 2013-02-04T12:39:37.403 回答