HttpServletResponse response,
Object[] helpers)
throws IOException, ServletException {
ActionErrors errors = new ActionErrors();
ModelResult modelResult = null;
try {
modelResult = getResult(
mapping,form,request,response,helpers);
}
catch (ModelException e) {
// Log and print to error console
servlet.log("Model Exception: ", e );
e.printStackTrace();
// General error message
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.general"));
// Generate error messages from exceptions
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.detail",e.getMessage()));
if (e.isCause()) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.detail",e.getCauseMessage()));
}
}
// -- Report any errors
if (!errors.empty()) {
saveErrors(request, errors);
if (mapping.getInput()!=null)
return (new ActionForward(mapping.getInput()));
// If no input page, use error forwarding
return (mapping.findForward(Tokens.FAILURE));
}
// -- Check for confirmation message
if (modelResult!=null)
saveMessage(errors,modelResult.getMessages());
// -- Save any confirmations
if (!errors.empty())
saveErrors(request, errors);
// -- Save the result
request.setAttribute(ModelResult.TOKEN,modelResult);
// -- Return empty (if appropriate) or continue
ActionForward forward = null;
if (modelResult.getSize()==0)
forward = mapping.findForward(Tokens.EMPTY);
if (forward!=null)
return forward;
// -- Return forward for successful outcome