JSF< h:commandButton>中的PrimeFaces的oncomplete属性.

JSF< h:commandButton>中的PrimeFaces的oncomplete属性.

问题描述:

我在标准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事件(有关更多详细信息,请参见

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...
});