ConfirmDialog出现,但立即消失 [英] confirmDialog appears but disappears immediately

查看:40
本文介绍了ConfirmDialog出现,但立即消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在SA和Primefaces论坛上阅读了类似的问题,但没有帮助.这是xhtml:

I have read similar questions on SA and the Primefaces forum but it did not help. Here is the 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. update是在表单提交响应到达后执行的.因此,确认对话框在打开后将进行更新,从而再次获得其默认外观.

The onclick is fired before the form submit request is sent. The update is performed after form submit response is arrived. So, the confirm dialog is updated after it's been opened and thus get its default appearance again.

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

You need to open it after the update. Use the oncomplete attribute instead of onclick.

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

这篇关于ConfirmDialog出现,但立即消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆