I didn't find an oncomplete
attribute available in some tags in PrimeFaces within a standard JSF <h:commandButton>
.
在标准的JSF
How can I get oncomplete-like functionality while using <h:commandButton>
?
在使用
1 个解决方案
#1
10
Since primefaces oncomplete
is equivalent to plain JSF success
event (for more details take a look at this answer comments , you should use the success
event in the following way:
由于“原始”oncomplete是等效于普通JSF成功事件(为了获得更多详细信息,请查看此回答注释,您应该以以下方式使用成功事件:
Inline solution
内联的解决方案
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="function(data) { if (data.status === 'success') { alert('complete'); }"
render="whatevet"></f:ajax>
</h:commandButton>
Another cleaner solution would be to use js function
另一个更简洁的解决方案是使用js函数。
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="myJsFunction"
render="whatevet"></f:ajax>
</h:commandButton>
In your js file add
在js文件中添加。
function myJsFunction(data) {
if (data.status === 'success') {
alert('complete');
}
}
In case you are looking for a way to detect the completion of non ajax submit you can adopt the following idea from here Detecting the File Download Dialog In the Browser
如果您正在寻找一种方法来检测非ajax提交的完成情况,您可以在浏览器中使用下面的方法来检测文件下载对话框。
The easiest solution would be to use
最简单的解决方法是使用。
$(document).ready(function () {
// check if some condition is meet and do something...
});
#1
10
Since primefaces oncomplete
is equivalent to plain JSF success
event (for more details take a look at this answer comments , you should use the success
event in the following way:
由于“原始”oncomplete是等效于普通JSF成功事件(为了获得更多详细信息,请查看此回答注释,您应该以以下方式使用成功事件:
Inline solution
内联的解决方案
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="function(data) { if (data.status === 'success') { alert('complete'); }"
render="whatevet"></f:ajax>
</h:commandButton>
Another cleaner solution would be to use js function
另一个更简洁的解决方案是使用js函数。
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="myJsFunction"
render="whatevet"></f:ajax>
</h:commandButton>
In your js file add
在js文件中添加。
function myJsFunction(data) {
if (data.status === 'success') {
alert('complete');
}
}
In case you are looking for a way to detect the completion of non ajax submit you can adopt the following idea from here Detecting the File Download Dialog In the Browser
如果您正在寻找一种方法来检测非ajax提交的完成情况,您可以在浏览器中使用下面的方法来检测文件下载对话框。
The easiest solution would be to use
最简单的解决方法是使用。
$(document).ready(function () {
// check if some condition is meet and do something...
});