You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by DG...@EvergreenInvestments.com on 2004/07/01 21:08:56 UTC
Returning an ActionError from an Action?
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
Re: Returning an ActionError from an Action?
Posted by Henrique VIECILI <vi...@softplan.com.br>.
use the method saveErrors(ActionErrors);
In you Action:
ActionErrors errors = new ActionErrors();
// validation
errors.add("property", new ActionError("key"));
saveErrors(errors);
Henrique Viecili
----- Original Message -----
From: DGraham@EvergreenInvestments.com
To: Struts Users Mailing List
Sent: Thursday, July 01, 2004 4:08 PM
Subject: Returning an ActionError from an Action?
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
Re: Returning an ActionError from an Action?
Posted by Bill Siggelkow <bi...@bellsouth.net>.
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