RichFaces a4j:commandButton 完成

RichFaces a4j:commandButton oncomplete

您好,我有这个带有 RF 4.5.2 的演示表单,oncomplete 执行了 3 次,我需要一种方法来在 ajax 调用之后执行一个方法,但只有一次,我认为这就是行为oncomplete 的,但如果没有,您可以提出任何其他想法来完成此操作:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head></h:head> 
<body>
    <rich:panel>
    <h:form>
        <a4j:commandButton  id="btnAccion" value="enviar" oncomplete="#{archivoAfipController.emptyAction()}"/>
    </h:form>
    </rich:panel>
</body> 
</html>

为了在提交时调用托管 bean 方法,您应该使用 action 属性。

<a4j:commandButton ... action="#{archivoAfipController.emptyAction}" />

oncomplete 必须表示客户端脚本表达式(因此,例如 JavaScript,从 JSF 的角度来看,它基本上是一个普通的香草 String!),应该在以下情况下执行ajax 操作已完成,响应已返回,并且已在客户端更新视图的所有必要部分。

另请参阅: