RichFaces 4.5-a4j:commandButton:未触发oncomplete

时间:2019-03-01 11:36:22

标签: richfaces jboss7.x jsf-2.2

从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";
    }

}

结果是:

  • 我可以看到警告说'onclick'
  • 但是我看不到提示“ onbeforedomupdate”或“ oncomplete”的警报
  • 在日志中看到我的bean方法doSomething被调用
  • 我还可以看到页面获取事件为oncomplete和onbeforedomupdate。

a4j:log结果:

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指向按钮...但是我会发现使用此信息构建“解决方法”很棘手。

感谢您的帮助!

0 个答案:

没有答案