Jsf confirmDialog出现,但立即消失

Jsf confirmDialog出现,但立即消失,jsf,primefaces,Jsf,Primefaces,我在SA和Primefaces论坛上读到过类似的问题,但没有帮助。下面是xhtml: <h:form id="form2" prependId="false"> <p:remoteCommand name="sendNameClicked" actionListener="#{reportBean.passName}"/> <p:remoteCommand name="updateDialog" update=":form3:dialogBox"/&

我在SA和Primefaces论坛上读到过类似的问题,但没有帮助。下面是xhtml:

<h:form id="form2" prependId="false">
    <p:remoteCommand name="sendNameClicked" actionListener="#{reportBean.passName}"/>
    <p:remoteCommand name="updateDialog" update=":form3:dialogBox"/>

    <p:commandButton style="display: none" id="displayDialog" type="button" onclick="cd.show(); return false;"/>
</h:form>
<h:form id="form3">
    <p:confirmDialog id ="dialogBox" message= "#{reportBean.getClickedAuthorLaius()}"
                     header="#{reportBean.nameClicked}#{reportBean.authorClicked.mostRecentAffiliation}"
                     widgetVar="cd"
                     severity="info"
                     >
        <h:outputText styleClass="ui-widget"  value="" escape="false" />
        <p:commandButton value="Draw the ring of #{reportBean.obtainFullName()}?" actionListener ="#{controllerBean.prepareNewSearch()}" action ="index?faces-redirect=true" oncomplete="cd.hide();"/>
        <p:commandButton value="No, stay on this page" onclick="cd.hide();" type="button" />
    </p:confirmDialog>
</h:form>


非常感谢任何帮助

在发送表单提交请求之前,会触发
onclick
更新
在表单提交响应到达后执行。因此,确认对话框在打开后会更新,从而再次获得其默认外观

您需要在更新后打开它。使用
oncomplete
属性而不是
onclick

<p:commandButton ... oncomplete="cd.show()"/>


commandButton由javascript函数触发,该函数执行以下操作:document.getElementById('displayDialog')。单击()。我这样修改了你的建议:但是什么也没有发生(对话框没有打开)。如何在使用onclick触发commandButton时使用oncomplete?谢谢!好的,我在这里提出了一个新问题:哦,我忽略了
type=“button”
,我根本没想到会出现在这里。移除它。不确定它是否能解决您的具体功能需求。毕竟,在这种构造中,隐藏的死按钮是非常奇怪的。我想知道为什么您没有在
updateDialog
函数中执行
cd.show()
,因为它的效果基本相同。根据迄今为止提供的代码和信息,使用
本身的
oncomplete
会更有意义。你去过荷兰吗?我欠你这么多瓶啤酒。不客气:)我目前没有任何参观的计划。