struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Siggelkow <bills...@bellsouth.net>
Subject Re: Returning an ActionError from an Action?
Date Thu, 01 Jul 2004 19:17:05 GMT
Sure ... just create the ActionErrors in your Action, save them using 
saveErrors(), then return the InputForward() ....

public class SaveDataAction extends Action {
   public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request,
                         HttpServletResponse response)
         throws Exception {
     ActionErrors errors = new ActionErrors();
     // do stuff with request params here

     // here is the ActionError stuff
     if ( somethingIsWrong() ) {
       errors.add(ActionErrors.GLOBAL_MESSAGE,
                  new ActionError("error.token"));
      // etc.
     }
     if (!errors.isEmpty()) {
       saveErrors(request, errors);
       return new ActionForward(mapping.getInputForward());
     }
     return mapping.findForward("success");
   }
}


DGraham@EvergreenInvestments.com wrote:

> 
> Currently constrained to Struts 1.0.
> 
> Due to the nature of my application, I am unable to use an ActionForm to 
> hold my form data (I am pulling it directly from the request parameter 
> map in the action).  As a result, I have to perform my validation in the 
> action, and I'm wondering if there is some way to leverage ActionErrors 
> from my action, or should I just use an application exception?
> 
> Dennis
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message