1 Reply Latest reply on Aug 23, 2007 3:13 PM by Stan Silvert

    Test a4j:commandButton

    Blondel Michaël Newbie

      I want to test an a4j:commandButton on my page.

      <h:inputText value="#{exaWzdProductBean.newIpAddress}" id="newIp" />
      <a4j:commandButton image="plus.png" action="#{exaWzdProductBean.addNewIp}" reRender="hostEdition"/>

      I call the action in my test like this :
      server = new ServerFacade(client);
      client.setParameter("formProduct:newIp", new String[] { "newIp" });

      But the method addNewIp is not call
      Thanks for your help

        • 1. Re: Test a4j:commandButton
          Stan Silvert Master

          There is an Ajax4JSF example in subversion. You can build and run it, or view the source here with fisheye:

          The a4j-repeat-rerender example has an <a4j:commandLink>, which is tested in exactly the same way as <a4j:commandButton>. You just need to give your commandButton an ID, and then click it with the Ajax4jsfClient. So the tag will look something like this:

          <a4j:commandButton id="my_command_button" image="plus.png" action="#{exaWzdProductBean.addNewIp}" reRender="hostEdition"/>

          Then in the test, you will have:
          ClientFacade client = new ClientFacade("/mypage.jsf");
           client.setParameter("newIp", new String[] { "newIp" });
           Ajax4jsfClient ajaxClient = new Ajax4jsfClient(client);

          After that, you can continue using your ClientFacade instance and your Ajax4jsfClient instance to set parameters and do more submits and/or AJAX calls to the server.

          Note also that as long as you don't have two fields in the same view with the ID "newIp", you don't have to include the form name "formProduct:".

          Stan Silvert