Good morning,
I need to subclass the LookupDispatchAction to write a
"BaseLookupDispatchAction" to centralize the UserRole check of my
application (etc.).
I try the following piece of code :
public abstract class BaseLookupAction extends LookupDispatchAction {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse
response) {
try{
//Check des users puis
ActionForward
succes=super.execute(mapping,form,request,response);
return succes;
}
catch(Exception ex)
{
ex.printStackTrace();
ActionMessages errors = new ActionMessages();
ActionMessage error = new
ActionMessage("error.fatal");
errors.add(ActionErrors.GLOBAL_MESSAGE,error);
saveErrors(request, errors);
return mapping.findForward("error");
}
The problem with that code is that I can not use my CustomErrorHandler
because the signature of the execute method does not throw an
exception.
So I must catch it and manually forward to an error page.
Is there a better way to do that?
}