未调用 h:commandLink 的 oncomplete 属性

oncomplete attribute of h:commandLink not invoked

我们正在从 JSF 1.2 迁移到 JSF 2.2.6 以及 RichFaces 4.5.2。面临 oncomplete 未被调用的问题。 onclick期间的JS函数被调用,但是oncomplete的JS函数没有被调用。这是怎么造成的,我该如何解决?

<h:commandLink ... onclick="ed();" oncomplete="cEd(#{rowIndex});">

There is indeed no such attribute in <h:commandLink>. You're most likely confusing with <a4j:commandLink> which does have that attribute.

你基本上有 2 个选择:

  1. 只需将 <h:commandLink> 替换为 <a4j:commandLink>

    <a4j:commandLink ... oncomplete="oncompleteFunction()" />
    
  2. <h:commandLink>.

    中嵌套带有事件处理程序的 <f:ajax>
    <h:commandLink ...>
        <f:ajax onevent="oneventFunction" /><!-- No parenthesis! -->
    </h:commandLink>
    
    function oneventFunction(data) {
        if (data.status === "success") {
            oncompleteFunction();
        }
    }
    

未来提示:只需阅读标签文档即可。链接在第 1 段中。