This content has been marked as final.
Show 1 reply
-
1. Re: Test a4j:commandButton
ssilvert Aug 23, 2007 3:13 PM (in response to mblondel)There is an Ajax4JSF example in subversion. You can build and run it, or view the source here with fisheye:
http://fisheye.jboss.org/browse/JSFUnit/trunk/jboss-jsfunit-examples/jboss-jsfunit-examples-ajax4jsf
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); ajaxClient.fireAjaxEvent("my_command_button");
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
http://www.jsfunit.org