struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thom Burnett" <thom.burn...@gmail.com>
Subject Re: Starting validation
Date Tue, 07 Nov 2006 17:47:42 GMT
Chris,

Following your advice, I've now found the proper settings for my resource
file.
With that fixed I can take out the sub class' validate() method and still
get a set of errors.
However, getting errors still depopulate's the form's fields. Again, I can
fix that by overriding the validate method (calling super) and that's not a
horrible solution - since it doesn't cost much work. But I don't think it
should be necessary and am wondering what's not set up right that would
cause that problem.

As near as I can see the form is being named and associated correctly but I
must be missing something.

On 11/7/06, Christopher Schultz <chris@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Thom,
>
> > struts-config.xml:
>
> This looks good.
>
> >      request.setAttribute("sessionForm", this) ; // If I don't do this
> the
> > form will be blank after an error.
>
> You really shouldn't have to do this. The form bean in the session will
> be called "donorBean" because of the value of the "name" attribute in
> your <action> mapping in struts-config.xml.
>
> >      request.setAttribute("errors", actionErrors) ;
>
> You shouldn't have to do this, either. Struts should be putting this
> ActionErrors object into the request for you. This is all you should need:
>
> >      return actionErrors ;
>
>
> > My validations.xml file - working partially
>
> When you say "partially", you mean that your form is re-displayed when
> validation doesn't pass, right? It's just that your errors do not show
> up and the form fields are blank. I think your validation is probably
> okay, but let's see.
>
> >         <arg0 key="validation.error.firstname"/>
>
> Do all of these properties actually exist in this file:
>
> /WEB-INF/ErrorMessages.properties (this is where you indicated your
> message resources were).
>
> I'm not sure what is the "standard" way to do this, but I have my
> message resources in my WEB-INF/classes directory, and I specify it like
> this:
>
>     <message-resources parameter="ApplicationMessages" null="false" />
>
> You might try adding 'null="false"' to see if you start getting messages
> like '???en_US.validation.error.firstname???' in your pages. If you get
> these messages, it means that struts can't find your error messages, but
> they are being properly generated and saved into the request.
>
> >      <html:errors/>
>
> This ought to print /something/. My guess is a properties file loading
> problem (see above).
>
> Hope that helps,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFFUMCr9CaO5/Lv0PARAg8pAJ0ToTTuxR2wC09xbRLXrGTNKfwa7ACfUhBI
> 41L+o5dayknOJDxN2PrQOl8=
> =T+ly
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message