Are you using Ajax4jsf or RichFaces? If so, you need to use either the RichFacesClient or Ajax4jsfClient (depending on your version). See the javadoc here: http://labs.jboss.com/file-access/default/members/jsfunit/freezone/apidocs/index.html
JSFClientSession.clickCommandLink() will always submit the whole form. That is because it is intended for use with the <h:commandLink> tag.
To click an Ajax-enabled link you need to use an Ajax-aware JSFUnit client.
I need to write a wiki on this topic, so please let me know what you are trying to do. Please show me your JSF tags and your JSFUnit test code.
Thank you Stan
We have written a postalcode component. When you enter postal code component(it is one zone) it will refresh the city zone where it will display the city name corresponding to that postal code.
We coded it is working fine in jsf, we want to write jsf test cases for this.
as i said it is refreshing whole page.
thank you for reply and i need the jar file i mean whole API for this Ajax4jsfClient to run.
Can u please let me know where i can get?
Are you using Ajax4jsf tags for this component? If not, then the Ajax4jsfClient won't help. You will need to create your own client that knows how to deal with your custom ajax tag.
To get the jar, you will need to build JSFUnit yourself. But if you wait a couple of days we are going to do a release and you should be able to download the beta 1 version.
Thank you stan
I am using normal jsf components.
So i can only use for ajax4jsf components?
is there any way i can call ajax submit with the client submit or form submit?
Give me some clue please
Yes, you can "roll-your-own" ajax submit. I need to write a full wiki article on that too!
0) Get a copy of the current DOM using JSFClientSession.getUpdatedDOM().
1) Create a PostMethodWebRequest with the org.jboss.jsfunit.facade.WebRequestFactory.
2) Add any params you need to the PostMethodWebRequest.
3) Call JSFClientSession.doWebRequest(), passing in the PostMethodWebRequest from step 2.
4) Get the HTML fragment returned by your Ajax request using JSFClientSession.getUpdatedDOM().
5) Update the old DOM from step 0 using the fragment from step 4. The org.jboss.jsfunit.facade.DOMUtil can help with this.
6) Add the text of the updated DOM to the http session: session.setAttribute(JSFUnitFilter.ALT_RESPONSE, updatedDOM.getText());
7) Make a request to the filter. See org.jboss.jsfunit.richfaces.JSFAJAX.createJSFUnitFilterRequest().
8) Call JSFClientSession.doWebRequest(), passing in the request created in step 7.
So that's how it is done for Ajax4jsf and RichFaces. You can look at the RichFaces Support package for the details. We are going to be working hard to make this much easier in future releases.
Thank you stan
But this JSFClientSession doesnt have the get UpdateDOM().
Will it be included in beta or what?
Thank you stan
In the latest jar i found the updateDom().
In the 4th step you mentioned to update the dom created at 0 step using the fragment from step 4 using DOMUtil.
I didnt get that point,plz can u detail it.
i am sending you the snippet i am trying....
Document doc= client.getUpdatedDOM();
WebRequestFactory fact=new WebRequestFactory(client);
The best thing to do is to look at the code in the org.jboss.jsfunit.richfaces package. Hopefully, you can see how it is done from that.
In step 4, I'm talking about the response that you get from your Ajax request. I don't know how your component works, but usually an Ajax request returns some fragment of HTML that is inserted/replaced in the DOM on the browser. Steps 4 and 5 are doing that part of the process.