Reputation: 391
I am using ICEfaces 3.2. I have a validator method defined for a particular ace:textAreaEntry
field. If the validation code inside my validator fails I am adding a faces error message to the context. I expected that when this error message gets added to the context, my actionListener
would not get executed. But what I notice is that even after adding faces error message to the context from my validator, the actionListener
gets executed. I thought that because the validation failed, faces won't execute the actionlistener
.
XHTML textareaentry code:
<ace:textAreaEntry
id="addrincountryofincorp"
value="#{strformbean.addrInCountryOfIncorp}"
required="true" styleClass="#{facesContext.validationFailed?'ui-state-error':''}"
label="Address in Country of Incorporation" cols="50" rows="5"
validator="#{strformbean.validateAddrLen}" />
Validator method:
public void validateAddrLen(FacesContext fc,UIComponent uc, Object obj){
int len = 0;
Map compAttr = uc.getAttributes();
log.debug("inside validateAddrLen...");
log.debug("obj = "+obj);
if(obj != null && ! obj.equals("")){
len = obj.toString().length();
if(len > 200){
Utility.addValMesgToContext(compAttr.get("label").toString() + " cannot exceed 200 Characters");
return;
}
}
}
Upvotes: 0
Views: 1043
Reputation: 11537
Validation is considered failed only if you actually throw a javax.faces.validator.ValidatorException
Try throwing an Exception with the FacesMessage inside:
FacesMessage msg = new FacesMessage("my validaton message");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(msg);
Upvotes: 1