I am developing an application in JSF 2 and I've got a question about the best practices.
What is the best practice for treating JSF message, I must treat the business Validation error messages via try/catch in managed Beans/CDI Bean or the best practice would be to treat all screen errors exceptions within a ExceptionHandlerWrapper
?
Example:
public String doCreate() {
try {
//...SomeCode
addInformationMessage(MESSAGE_SUCCESS_DATA_INSERTED);
} catch (BusinessValidationException bve) {
addErrorMessage(bve);
return Outcome.FAILURE;
} catch (WebValidationException wve) {
addErrorMessage(wve);
return Outcome.FAILURE;
} catch (BusinessException e) {
throw new WebException(e);
}
return Outcome.SUCCESS;
}
Or in a custom ExceptionHandlerWrapper
:
public class AppExceptionHandler extends ExceptionHandlerWrapper {
// my implemantation
}
I researched a lot about this subject, but found nothing very clear, what is the best way to treat known error exceptions?
Thank for attention