问题
What would the method facesContext.isValidationFailed()
return after the Render Response Phase when the validation fails? It returns false
for me in this case.
回答1:
It will only return true
when FacesContext#validationFailed() has been called by the JSF validation internals or by your own code as follows:
FacesContext.getCurrentInstance().validationFailed();
As far JSF internal code is concerned, only UIInput#processValidators() and UIViewParameter#processValidators() will implicitly call this method whenever a ValidatorException has been caught.
If it returns false
for you, then you're apparently doing validation in a non-standard way. For example inside the action method, while you should be using a real Validator for this.
来源:https://stackoverflow.com/questions/9474151/isvalidationfailed-default-value