1 Reply Latest reply on Oct 20, 2010 1:09 PM by Leo K

    programatticaly set oncomplete for a4j:support

    Leo K Newbie

      Hi

       

      This snippet works

       

              <h:inputText value="#{teste3.campoTxt}" >
                    <a4j:support
                        ajaxSingle="true"
                        actionListener="#{teste3.executa}"
                        event="onblur"
                        oncomplete="#{teste3.jsExec}"/>
                </h:inputText>

       

      But

       

      UIAjaxSupport ajax =(UIAjaxSupport)application.createComponent(UIAjaxSupport.COMPONENT_TYPE);
      ajax.setOncomplete(yourStringHere);  <= should not be an object or something?

       

      Parameter expected is a String.

       

      If I try to add yourStringHere = #{apresentacaoQuestionarioMB.funcaoRetorno}

       

      then I´ve got

       

      Erro: illegal character
      A4J.AJAX.Submit('form',event,{'control':this,'oncomplete':function(request,event,data){#{apresentacaoQuestionarioMB.funcaoRetorno}},'similarityGroupingId':'form:ajaxIDgen6','parameters':{'ajaxSingle':'form:pergunta2206','form:ajaxIDgen6':'form:ajaxIDgen6'

       

      Then I´ve tried to use the data attribute

       

      UIAjaxSupport ajax =(UIAjaxSupport)application.createComponent(UIAjaxSupport.COMPONENT_TYPE);
      MethodExpression me = criarMetodoExpressao(application,metodoAtualizacaoDados,null, new Class[] { ActionEvent.class });
      ajax.setAjaxSingle(true);
      ajax.addActionListener(new MethodExpressionActionListener(me));
      ajax.setId("ajax"+this.obterProximoId());
      ValueExpression jsRetornoVE = criarValorExpressao(application,
                                  "#{apresentacaoQuestionarioMB.funcaoRetorno}",
                                  String.class);
      ajax.setData(jsRetornoVE);
      //ajax.setOncomplete("#{apresentacaoQuestionarioMB.funcaoRetorno}");
      ajax.setOncomplete("alert(data)");

       

      This time I´ve got

       

      GRAVE: Error Rendering View[xxx.xhtml]
      javax.faces.FacesException: Error in conversion Java Object to JavaScript
          at org.ajax4jsf.javascript.ScriptUtils.writeScriptToStream(ScriptUtils.java:170)
          at org.ajax4jsf.javascript.ScriptUtils.writeScriptToStream(ScriptUtils.java:174)
          at org.ajax4jsf.javascript.ScriptUtils.writeScriptToStream(ScriptUtils.java:65)
          at org.ajax4jsf.javascript.ScriptUtils.writeScriptToStream(ScriptUtils.java:174)
          at org.ajax4jsf.javascript.ScriptUtils.writeScriptToStream(ScriptUtils.java:174)

      ... (loop here?)

       

      Any ideas?

       

      TIA

       

      Leo K.