Hartmut,

I do it at the end of an action's perform() method using the "construction"
given in my previous reply!

What I describe is only valid if your controller checks for errors itself.
In case you let Struts handle the validation automatically, I advice you to
look at the Struts source code.
The following code snippet is from the Action.java class:

    /**
     * The request attributes key under which your action should store an
     * <code>org.apache.struts.action.ActionErrors</code> object, if you
     * are using the corresponding custom tag library elements.
     */
    public static final String ERROR_KEY = "org.apache.struts.action.ERROR";

Concluding: the errors are stored in the request (session?) attribute
"org.apache.struts.action.ERROR".

Regards,
Guus

----- Original Message -----
From: "Hartmut Bernecker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 18, 2001 12:48
Subject: Re: Displaying errors when validating forms (ActionErrors)


> No, I think I did not!
> My validate Method looks like that, it returns Errors back to the
> controller servlet.
> - Where is the place to save the errors in the request???
>
>
>    public ActionErrors validate(ActionMapping pMapping,
> HttpServletRequest pRequest)
>    {
>       System.out.println("VALIDIERE");
>       ActionErrors errors = new ActionErrors();
>       if (iBenutzer == null || iBenutzer.length() < 1)
>       {
>          errors.add("benutzungsname",
>              new ActionError("error.login.benutzername.required"));
>       }
>       if (iPasswort == null || iPasswort.length() < 1)
>       {
>          errors.add("passwort",
>              new ActionError("error.login.passwort.required"));
>       }
>       if (iSprache == null || iSprache.length() < 2 ||
> iSprache.equals("blank"))
>       {
>          errors.add("sprache",
>              new ActionError("error.login.passwort.required"));
>       }
>
>       return errors;
>    }
>
>
>
> Guus Holshuijsen schrieb:
> >
> > Do you save your errors?
> >
> >     // Report any errors we have discovered
> >     if ( !errors.empty() )
> >     {
> >       saveErrors( request, errors );
> >     }
> >
> > Regards,
> > Guus
> >
> > ----- Original Message -----
> > From: "Hartmut Bernecker" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, July 18, 2001 11:55
> > Subject: Displaying errors when validating forms (ActionErrors)
> >
> > > Hallo,
> > >
> > > I have a problem to display ActionErrors. I use the validate-Method to
> > > validate forms, like that:
> > >
> > > ------------------------------
> > > public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > > request) {
> > > ActionErrors errors = new ActionErrors();
> > > if (iBenutzer == null || iBenutzer.length() < 1) {
> > > errors.add("benutzungsname", new
> > > ActionError("error.login.benutzername.required"));
> > > }}
> > > ------------------------------
> > >
> > > But when I want to display that error, I can't see anything. Why?????
> > >
> > > * errors.header=<ul>
> > >   errors.footer=</ul>
> > >   error.login.benutzername.required=that is an error ...
> > >
> > >   is in the property-file! That property-file is available (set in
> > > web.xml)!
> > >
> > > * the JSP contains:
> > >   <html:errors/>
> > >   <html:errors property="benutzungsname"/>
> > >
> > > Who can help me?!
> > > What is wrong??
>

Reply via email to