对话框不会关闭原子 [英] dialog will not close primefaces
问题描述
< 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屋!