1 Reply Latest reply on Apr 23, 2010 1:02 PM by sv kap

    HtmlAjaxSupport + IllegalArgumentException wrong number of arguments

    sv kap Newbie

      Hi.

       

      I have some problems with HtmlAjaxSupport.

       

      Here is my jsf page:

                               <h:panelGrid columns="2"
                                      columnClasses="pnlGrdClassMsg, pnlGrdClassLong">
                                      <h:panelGrid id="msgPanelGridId" binding="#{profileBean.msgPanelGrid}" />
                                     
                                      <a4j:commandLink reRender="msgPanelGridId" ajaxSingle="true"
                                          action="#{profileBean.newMessenger}">
                                          <h:outputText value="Add new messenger" />
                                      </a4j:commandLink>
                                  </h:panelGrid>

       

      Part of my code for dynamic messenger creation:

       

       

              // create input
              HtmlInputText input = new HtmlInputText();
              String imsUserInputId = imsUserInput_Id + imsNumber;
              input.setId(imsUserInputId);
              input.setSize(20);
              input.setMaxlength(40);
              input.setValue(new String(ims.getUsername()));
              MethodExpression inputActionExpression = expressionFactory
                      .createMethodExpression(elContext,
                              "#{profileBean.msgInputValueChange}", null,
                              new Class[] { ValueChangeEvent.class });
              MethodExpressionValueChangeListener inputListener = new MethodExpressionValueChangeListener(
                      inputActionExpression);
              input.addValueChangeListener(inputListener);

              HtmlAjaxSupport as = new HtmlAjaxSupport();
              as.setEvent("onchange");
              as.setId(imsAjaxUserInput_Id + imsNumber);
              as.setActionExpression(inputActionExpression);
              as.setReRender(pnlGrid.getId());
              input.getChildren().add(as);
             
              pnlGrid.getChildren().add(input);

       

      When I click on newMessenger command link I get this exception:

       

       

      exception

      javax.servlet.ServletException: wrong number of arguments
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:323)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

      root cause

      java.lang.IllegalArgumentException: wrong number of arguments
           sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           java.lang.reflect.Method.invoke(Method.java:597)
           com.sun.el.parser.AstValue.invoke(AstValue.java:234)
           com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
           javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
           javax.faces.component.UICommand.broadcast(UICommand.java:315)
           org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
           org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
           com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
        • 1. Re: HtmlAjaxSupport + IllegalArgumentException wrong number of arguments
          sv kap Newbie

          Hi.

           

          Actually the problem was in:

           

          MethodExpression inputActionExpression = expressionFactory
                          .createMethodExpression(elContext,
                                  "#{profileBean.msgInputValueChange}", null,
                                  new Class[] { ValueChangeEvent.class });
          
          .....
          
          as.setActionExpression(inputActionExpression);
          

           

          HtmlAjaxSupport requre method with no parameters. So this works:

           

           

          MethodExpression inputActionExpression = expressionFactory
                          .createMethodExpression(elContext,
                                  "#{profileBean.msgInputValueChange}", null,
                                  new Class[] {});
          
          .....
          
          as.setActionExpression(inputActionExpression);