struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: how to generate GLOBAL errors using Struts validation framework
Date Wed, 01 Nov 2006 17:23:42 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robin,

> When the user submits the form with more than one fields left blank (or
> with incorrect values), I want to show a
> general (GLOBAL) message on top of the form saying
> 
> "Following shown mandatory fields were provided with incorrect values"

How about putting something like this in your JSP (haven't worked with
JSP in forever, but this ought to get the point across):

<jstl:if test="$errors">
   <p class="error">
      <struts:msg key="error.title.some-fields-are-bad" />
   </p>
</jstl:if>

> b) And then I want to show a field-specific error message beside each
> input field that failed the validation rules.

Umm...

<jstl:if test="$errors.form-field-1">
    <jstl:echo value="$errors.form-field-1" />
</jstl:if>
<label for="form-field-1">Field</label>
<input id="form-field-1" name="form-field-1" ... />

etc.

Does that help?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFSNge9CaO5/Lv0PARAnMUAKCEW3KwUC3YaNg1SyIc1ymI3kme7gCeLiEL
ObQSWl9yGmcsoQSrfm78/h4=
=1rei
-----END PGP SIGNATURE-----

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


Mime
View raw message