对话框不会关闭原子 [英] dialog will not close primefaces

查看:159
本文介绍了对话框不会关闭原子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的一个页面上有一个对话框。它开好了它工作正常,如果您使用页面上的按钮,它关闭。但是,如果您尝试使用对话框中的x,则不会关闭。我相信这与我在对话框上有一个输入字段的事实有关,但我不确定。我很抱歉,如果这是一个骗子,我找不到类似的职位。

 < p:commandButton action =#{phoneListBean.debugger}
value =Merge Unqiueonclick = mdlg.show();
update =:pmsg,:createNewPanel,:listform/>

< p:dialog id =mdialogheader =合并UnqiuewidgetVar =mdlg
appendToBody =true>
< h:form id =mform>
< h:panelGrid columns =2cellpadding =5id =m>
< h:outputLabel for =listNamevalue =输入列表名称:/>
< p:inputText value =#{phoneListBean.mergeList.name}id =listName/>


< p:commandButton action =#{phoneListBean.mergeUnique}
value =Merge Unqiueupdate =:pmsg,:listform
的onclick = mdlg.hide(); />
< / h:panelGrid>
< / h:form>

< / p:dialog>

提前感谢帮助。

解决方案

您的问题是您不想使用 onclick 属性用于显示和隐藏对话框的Primefaces按钮。点击事件可能无法在回发之前调用,因为这些按钮不是启用Ajax。



相反,您应该使用 oncomplete 属性。这将通知JavaScript事件仅在服务器回发发生后执行,这意味着 show()将显示已更新的对话框内容, hide )仅在服务器端执行完成后才会发生。


I have a dialog on one of my pages. It opens fine. It works fine if you use the button on the page, it closes. However, if you try and "x" out of the dialog it will not close. I believe it is related to the fact that I have an input field on the dialog, but I am not sure. I apologize if this is a dupe, I could not find a similar post.

        <p:commandButton action="#{phoneListBean.debugger}"
            value="Merge Unqiue" onclick="mdlg.show();"
            update=":pmsg, :createNewPanel, :listform" />

        <p:dialog id="mdialog" header="Merge Unqiue" widgetVar="mdlg"
            appendToBody="true">
            <h:form id="mform">
                <h:panelGrid columns="2" cellpadding="5" id="m">
                    <h:outputLabel for="listName" value="Enter the List Name:" />
                    <p:inputText value="#{phoneListBean.mergeList.name}" id="listName" />


                    <p:commandButton action="#{phoneListBean.mergeUnique}"
                        value="Merge Unqiue" update=":pmsg, :listform"
                        onclick="mdlg.hide();" />
                </h:panelGrid>
            </h:form>

        </p:dialog>

Thanks in advance for the help.

解决方案

Your problem is that you don't want to use the onclick attribute with Primefaces buttons for displaying and hiding the dialogs. The click event may not get invoked before the postback because these buttons are not Ajax enabled.

Instead you should use oncomplete attribute. This will notify the Javascript event to execute only after the server postback has occurred, meaning that show() will display already updated dialog contents, and hide() will occur only after the server side execution has finished.

这篇关于对话框不会关闭原子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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