You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andrew Steady <An...@kinesis.com> on 2001/04/26 10:29:09 UTC

adding an ActionError in the Action

Hi,



If I form validates itself OK but subsequently the Action needs to raise an
      input error to the user, in my case security failed, how is it
      possible to add an ActionError for the errors tag to pick up. The
      only way to give struts a collection of ActionErrors is by returing
      it from the ActionForm.validate() method.



I presume if I know the name of the ActionErrors bean which the error tag
      accesses I could manually create it in the Action and add it to the
      correct scope so that the errors tag could pick it up.



Has anybody encountered this problem before?



Cheers,



Andy S



Re: adding an ActionError in the Action

Posted by Jean-Noel Ribette <je...@improve.fr>.
There is a method in the Action class you can use to do this: saveErrors(HttpServletRequest request, ActionErrors
errors).
You can also do directly :

request.setAttribute("org.apache.struts.action.ERROR", errors)

So all you have to do is create an ActionErrors object, put errors in it, save it in the request and return (new
ActionForward(mapping.getInput())) to return to the form.

This is illustrated in the example application.

Jean-Noel

----- Original Message -----
From: Andrew Steady <An...@kinesis.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 26, 2001 10:29 AM
Subject: adding an ActionError in the Action


>
> Hi,
>
>
>
> If I form validates itself OK but subsequently the Action needs to raise an
>       input error to the user, in my case security failed, how is it
>       possible to add an ActionError for the errors tag to pick up. The
>       only way to give struts a collection of ActionErrors is by returing
>       it from the ActionForm.validate() method.
>
>
>
> I presume if I know the name of the ActionErrors bean which the error tag
>       accesses I could manually create it in the Action and add it to the
>       correct scope so that the errors tag could pick it up.
>
>
>
> Has anybody encountered this problem before?
>
>
>
> Cheers,
>
>
>
> Andy S
>
>
>


Re: adding an ActionError in the Action

Posted by Rajan Gupta <rg...@yahoo.com>.
Have u looked at saveErrors() method of Action object. It should do the
work that you wish to do, just remember to use the errors tag in your page

 --Andrew Steady <An...@kinesis.com> wrote:
> 
> Hi,
> 
> 
> 
> If I form validates itself OK but subsequently the Action needs to raise
> an
>       input error to the user, in my case security failed, how is it
>       possible to add an ActionError for the errors tag to pick up. The
>       only way to give struts a collection of ActionErrors is by
> returing
>       it from the ActionForm.validate() method.
> 
> 
> 
> I presume if I know the name of the ActionErrors bean which the error
> tag
>       accesses I could manually create it in the Action and add it to
> the
>       correct scope so that the errors tag could pick it up.
> 
> 
> 
> Has anybody encountered this problem before?
> 
> 
> 
> Cheers,
> 
> 
> 
> Andy S
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/