问题描述
我在标准JSF <h:commandButton>
的PrimeFaces的某些标签中找不到可用的oncomplete
属性.
I didn't find an oncomplete
attribute available in some tags in PrimeFaces within a standard JSF <h:commandButton>
.
使用<h:commandButton>
时如何获得类似oncomplete的功能?
How can I get oncomplete-like functionality while using <h:commandButton>
?
推荐答案
由于质数oncomplete
等同于普通的JSF success
事件(有关更多详细信息,请参见,您应通过以下方式使用success
事件:
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:
在线解决方案
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="function(data) { if (data.status === 'success') { alert('complete'); }"
render="whatevet"></f:ajax>
</h:commandButton>
另一个更清洁的解决方案是使用js函数
Another cleaner solution would be to use js function
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="myJsFunction"
render="whatevet"></f:ajax>
</h:commandButton>
在您的js文件中添加
function myJsFunction(data) {
if (data.status === 'success') {
alert('complete');
}
}
如果您正在寻找检测非Ajax提交是否完成的方法,则可以从此处在浏览器中检测文件下载对话框
最简单的解决方案是使用
The easiest solution would be to use
$(document).ready(function () {
// check if some condition is meet and do something...
});
这篇关于JSF< h:commandButton>中的PrimeFaces的oncomplete属性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!