struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Volker Karlmeier <vol...@magiccode.eu>
Subject Re: Struts 2 & Dynamic Validation results
Date Mon, 21 Apr 2008 21:07:44 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Hi,

in an action class, just use
String[] params=new String[] {"/*your Parameter String*/0", "/*your
Parameter String*/1",...,"/*your Parameter String*/n"};
addFieldError("a", getText("errors.required", params));
using the methods getText(String key, String[] params) from the class
com.opensymphony.xwork2.TextProvider. (see
http://struts.apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/TextProvider.html)

Volker




JRD schrieb:
> I am try to migrate an app from struts 1 -> 2
>
> I am trying to do basic validation on a form.  Fields a and b are
> required.
>
> <field name="a"> <field-validator type="requiredstring"> <message
> key="errors.required"/> </field-validator> </field> <field
> name="b"> <field-validator type="requiredstring"> <message
> key="errors.required"/> </field-validator> </field>
>
> in the resource bundle I have
>
> errors.required={0} is required.
>
> How do you put dynamic values into these messages so that it shows
> up:
>
> [blah blah blah] is required. [Some other field] is required.
>
> Thanks in advance, Jonathan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFIDQIfx4KjH6Tk4MMRApzOAJwM6rCac3SJEhSgUd8vvKWkLPbgigCbBr/S
fkcA8BDenh3e5OUAkMDBGSs=
=tVaC
-----END PGP SIGNATURE-----


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