You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sgarlata Matt <sg...@bah.com> on 2003/09/27 18:42:19 UTC

Re: Accessing action error problem

You can use the attached JSPs to display all the attributes in the request.
Just look for the attribute that stores the errors.  In general when I was
starting with Struts I found the attached JSPs very helpful because you can
see the types of information Struts stores for you and where it is stored.
Also, if you look at the Globals class the locations for many of these
attributes are recorded there.  I just find it easier to look at the actual
attributes in the request using the attached JSPs rather than hunting
through the javadoc of the Globals class.

Matt
----- Original Message ----- 
From: "Pete Serafin" <ps...@hcrnetwork.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, July 02, 2003 1:32 PM
Subject: Accessing action error problem


> Im am trying to determine a way to find out if an ActionError exists in my
request.  I create an error in my action class as follows:
>
> ActionErrors errors = new ActionErrors();
> errors.add( "startDate",new
ActionError("error.form.requiredField.startDate") );
> saveErrors( request, errors );
>
> I can access the error using the <html:errors /> tag, but all I actuallt
want to do is check that the startDate error is not null. How can I try to
grab this object from the HttpServletRequest object?
>
> The whole point is to execute some logic that hides some html if an error
exists.  Any suggestions?
>
> Pete Serafin
> HealthCare Recruiters International
>

Re: Accessing action error problem

Posted by Manish Singla <Ma...@Sun.COM>.
a) Get ServletContext of Globals.ERROR_KEY.
b) Typecast to ActionErrors
c) Use     errors.get(property)
d) (c) wil return Iterator ......


Sgarlata Matt wrote:

> You can use the attached JSPs to display all the attributes in the request.
> Just look for the attribute that stores the errors.  In general when I was
> starting with Struts I found the attached JSPs very helpful because you can
> see the types of information Struts stores for you and where it is stored.
> Also, if you look at the Globals class the locations for many of these
> attributes are recorded there.  I just find it easier to look at the actual
> attributes in the request using the attached JSPs rather than hunting
> through the javadoc of the Globals class.
>
> Matt
> ----- Original Message -----
> From: "Pete Serafin" <ps...@hcrnetwork.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, July 02, 2003 1:32 PM
> Subject: Accessing action error problem
>
> > Im am trying to determine a way to find out if an ActionError exists in my
> request.  I create an error in my action class as follows:
> >
> > ActionErrors errors = new ActionErrors();
> > errors.add( "startDate",new
> ActionError("error.form.requiredField.startDate") );
> > saveErrors( request, errors );
> >
> > I can access the error using the <html:errors /> tag, but all I actuallt
> want to do is check that the startDate error is not null. How can I try to
> grab this object from the HttpServletRequest object?
> >
> > The whole point is to execute some logic that hides some html if an error
> exists.  Any suggestions?
> >
> > Pete Serafin
> > HealthCare Recruiters International
> >
>
>   ------------------------------------------------------------------------
>                 Name: debug.zip
>    debug.zip    Type: Zip Compressed Data (application/x-zip-compressed)
>             Encoding: base64
>
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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