RichFaces 4.5 - a4j:commandButton:未触发 oncomplete

RichFaces 4.5 - a4j:commandButton : oncomplete not triggered

从 JSF 2.1/RichFaces 4.3.0 迁移到 JSF 2.2/RichFaces 4.5 后。17.Final,我注意到我的 a4j:commandButton 类型的按钮不再捕获 oncomplete 事件。 服务器:JBoss EAP 7.0.2.Final

这是我制作的一个简单的测试页面:

<h:body>

    <h:form id="testForm">
        <a4j:commandButton 
            id="doTest" 
            onclick="alert('onclick');"
            onbeforedomupdate="alert('onbeforedomupdate');"
            oncomplete="alert('oncomplete');"
            value="TEST"
            action="#{a4jCommandButtonTester.doSomething()}" execute="@this"
            render="@none" limitRender="true"
        />

        <a4j:log mode="popup" level="debug" />
    </h:form>

</h:body>

调用那个简单的方法:

@Named
public class A4jCommandButtonTester {

    public String doSomething() {
        System.out.println("Doing something");
        return "something";
    }

}

结果是:

a4j:记录结果:

debug[12:16:56.266]: New request added to queue. Queue requestGroupingId changed to testForm:doTest
debug[12:16:56.266]: Queue will wait 0ms before submit
debug[12:16:56.268]: richfaces.queue: will submit request NOW
info [12:16:56.268]: Received 'begin' event from <input id=testForm:doTest ...>
info [12:16:56.304]: Received 'beforedomupdate' event from <input id=testForm:doTest ...>
debug[12:16:56.305]: Server returned responseText: <?xml version='1.0' encoding='UTF-8'?> <partial-response id="j_id1"><changes><update id="j_id1:javax.faces.ViewState:0"><![CDATA[256733305988132353:-1254866772301146127]]></update></changes></partial-response>
info [12:16:56.307]: Listing content of response changes element:
Element update for id=j_id1:javax.faces.ViewState:0
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[256733305988132353:-1254866772301146127]]></update>
debug[12:16:56.309]: richfaces.queue: ajax submit successfull
debug[12:16:56.309]: richfaces.queue: Nothing to submit
info [12:16:56.310]: Received 'success' event from <input id=testForm:doTest ...>
info [12:16:56.311]: Received 'complete' event from <input id=testForm:doTest ...>

我的问题:为什么 a4j:commandButton 没有捕捉到这些事件? 如何让它工作?

备注: 如果我这样说:

<h:outputScript>
    jQuery(document).ready(function() {
        jQuery(document).on('ajaxcomplete', function(event) {
            alert('ajaxcomplete');
            console.log(event);
            console.log(event.target);
            console.log(event.currentTarget.activeElement);
        });
    });
</h:outputScript>

我得到了事件的目标:它是形式... event.currentTarget.activeElement 指向按钮...但我发现使用此信息构建 'workaround'.

很棘手

感谢您的帮助!

终于找到问题的根源了

我正在使用来自 OmniFaces 的这个阶段侦听器:org.omnifaces.eventlistener.ResetInputAjaxActionListener

但是根据我在 OmniFaces 网站上看到的内容,对于 JSF 2.2 迁移,我应该从 OmniFaces 1.x 迁移到 2.x(我没有):

OmniFaces 2.x requires Java 1.7, JSF 2.2, EL 2.2, Servlet 3.0, CDI 1.1, WS 1.1

然后我将 OmniFaces 的依赖版本更新到 2.7,它现在​​可以正常工作了。