如果 update=“dlg",Primefaces p:dialog 并不总是出现在命令按钮中 [英] Primefaces p:dialog doesn't always show up if update="dlg" in commandButton
问题描述
我有一个像这样的 jsf facelet 页面(极其简化的版本):
I have a jsf facelet page like this (extremely simplified version):
<h:form id="frmAnagPersonName">
<p:commandButton value="Edit" icon="ui-icon-gear"
update="@form :frmEdit"
onsuccess="_dlgEdit.show()"/>
...
<p:dataTable etc...
...
</h:form>
<p:dialog id="dlgEdit" widgetVar="_dlgEdit" dynamic="true" modal="true" closable="true"
header="Person Identity">
<h:form id="frmEdit" >
<p:panelGrid id="pnlEdit" columns="2">
<p:outputLabel id="lblName" for="eName" value="Name"/>
<p:inputText id="eName" value="#myBean.personName}"
</p:panelGrid>
</h:form>
</p:dialog>
它工作正常,直到我在对话框中放置了一个动态标题:
It works fine, until I put a dynamyc Header in the dialog:
<p:dialog ... header="#{myBean.header}" ... >
此时我必须更改 p:commandButton
中的 update
属性:
at which point i have to change the update
attribute in the p:commandButton
:
update="@form :dlgEdit"
但在这种情况下,对话框只会在第一次点击按钮时出现.不会出现第二次,然后再次出现...
为什么?如何让对话框始终显示?
But in this case the dialog will show up only at the first click on the button. It won't show up the second time, then again show up...
Why? How can I have the dialog show up always?
谢谢
推荐答案
使用 oncomplete
属性代替 onsuccess
属性.
Use the oncomplete
attribute instead of onsuccess
attribute.
<p:commandButton ... update="@form :dlgEdit" oncomplete="_dlgEdit.show()" />
onsuccess
属性在 ajax 响应成功到达时直接调用,但在基于 ajax 响应执行 ajax 更新之前很久.oncomplete
属性在 ajax 更新成功完成时被调用.另请参阅
.
The onsuccess
attribute is invoked directly when ajax response is successfully arrived but long before the ajax updates are performed based on the ajax response. The oncomplete
attribute is invoked when the ajax updates are successfully completed. See also the tag documentation of <p:commandButton>
.
基本上,这是事件调用顺序:
Basically, this is the event invocation order:
onclick
处理程序被调用- ajax 请求是基于
process
用表单数据准备的 onbegin
处理程序被调用- 发送ajax请求
- ajax 响应成功获取(HTTP 状态码为 200)
onsuccess
处理程序被调用- ajax 更新基于
update
在 HTML DOM 中执行 oncomplete
处理程序被调用
onclick
handler is invoked- ajax request is prepared with form data based on
process
onbegin
handler is invoked- ajax request is sent
- ajax response is successfully retrieved (HTTP status code is 200)
onsuccess
handler is invoked- ajax updates are performed in HTML DOM based on
update
oncomplete
handler is invoked
这篇关于如果 update=“dlg",Primefaces p:dialog 并不总是出现在命令按钮中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!