In the JSF project I’m working Exceptions thrown by Beans are usually handled by JSF redirecting the user to an error page, but when they are raised inside a Bean validation method, JSF handles them displaying in the relative <h:message> tag the Exception message, instead.
I would like that Exceptions raised in validation methods be handled as the other Exceptions raised from Beans are. Is there a way to achieve that?
The kind of validation I’m using is through backing-bean validator method, for example in JSF page:
<h:inputText value="#{Bean.field}" validator="#{Bean.validate}" />
and, in backing bean code:
public void validate(FacesContext context, UIComponent component, Object value){
// validation logic here
}
Thanks, Andrea
This is “by design”.
Transform that validator into a fullworthy class which implements
Validator. Any exceptions other thanValidatorExceptionthrown in there will result in a HTTP 500 error page.E.g.
which you register as
<validator>infaces-config.xmland use as follows in the inputs
or