• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how would I check if there are errors in Action execute method

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Within my execute method I wish to check if there are errors i.e. if the form was not fully completed

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
DynaValidatorForm registrationForm = (DynaValidatorForm)form;

if(no errors)
return (mapping.findForward("success"));
else
return (mapping.findForward("failure"));

thank you for your time
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
DynaValidatorForm registrationForm = (DynaValidatorForm)form;
ActionErrors errors = new ActionErrors();

// add some errors if something bad happened

if(!errors.isEmpty())
return (mapping.findForward("success"));
else
saveErrors(request, errors);
return (mapping.findForward("failure"));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic