-
1. Re: How to test input & rich:ajaxValidator event="onblur" & rich:message
ssilvert Apr 16, 2010 8:52 AM (in response to jadtn)1 of 1 people found this helpfulHi Adrien,
I've never tried this before. You might need to Using the HtmlUnit API with JSFUnit and also post on the HtmlUnit mailing list to ask exactly how/when onblur gets fired.
Stan
-
2. Re: How to test input & rich:ajaxValidator event="onblur" & rich:message
jadtn Apr 16, 2010 3:49 PM (in response to jadtn)To test ajaxValidator it is need to use a HtmlElement to change the component focus
Here a sample code
//set focus on the input to modify
setFocusOn("
nupseudo
");
//update the input
client.setValue("nupseudo
", newUser);
//change the focus
setFocusOn("anotherInputForExample");//check the error message
checkContainsMsg("
nupseudo
", "excpected error message")public void setFocusOn(String componentId){
HtmlPage p = (HtmlPage) client.getContentPage();//JSFClientSession
HtmlElement m = p.getHtmlElementById(componentId);
p.setFocusedElement(m);//change the focus to declenche ajaxvalidar
}public void checkContainsMsg(String cptid, String msg) {
Iterator<FacesMessage> msgs = FacesContext.getCurrentInstance().getMessages(cptid);
String allmsg="";
while (msgs.hasNext()) {
FacesMessage m = msgs.next();
allmsg= allmsg+ "[sum='"+m.getSummary()+"',Det='"+m.getDetail()+"',SEV="+m.getSeverity()+"]";
if (msg.equals(m.getSummary()) || msg.equals(m.getDetail())) {
return;
}
fail(allmsg+ " no msg for component '" + cptid + "' msg=" + msg);
} -
3. Re: How to test input & rich:ajaxValidator event="onblur" & rich:message
ssilvert Apr 16, 2010 4:07 PM (in response to jadtn)I figured it would take something like that. Thanks for sharing your solution.
Stan