You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Deadman, Hal" <ha...@tallan.com> on 2001/02/22 01:07:16 UTC

passing substitution parameters to ActionError still working?

I have a form where I call the following (where UserForm.MIN_PASSWORD_LENGTH
is an int):
errors.add("password", new ActionError("error.user.passwordinvalid",
String.valueOf(UserForm.MIN_PASSWORD_LENGTH)));

which references this in the ApplicationResource.properties file:
error.user.passwordinvalid=<li>The password must contain at least {0}
characters.</li>
 
But the html:error tag displays this:
*	The password must contain at least [Ljava.lang.Object;@14f467
characters. 
 
I could have sworn that this used to work but it doesn't anymore for me.
Does passing parameters to ActionError objects still work for everyone with
recent builds? If it still works then I must have broke something. 
 
Thanks, Hal

Re: passing substitution parameters to ActionError still working?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Deadman, Hal" wrote:

>  I have a form where I call the following (where
> UserForm.MIN_PASSWORD_LENGTH is an int):errors.add("password", new
> ActionError("error.user.passwordinvalid",
> String.valueOf(UserForm.MIN_PASSWORD_LENGTH)));which references this
> in the ApplicationResource.properties
> file:error.user.passwordinvalid=<li>The password must contain at least
> {0} characters.</li> But the html:error tag displays this:
* The password must contain at least [Ljava.lang.Object;@14f467
> characters.  I could have sworn that this used to work but it doesn't
> anymore for me. Does passing parameters to ActionError objects still
> work for everyone with recent builds? If it still works then I must
> have broke something. Thanks, Hal

You should be able to pass the length as an object of type Integer, and
let the message formatting methods worry about converting it to a
String:

    errors.add("password", new ActionError("error.user.passwordinvalid",

        new Integer(UserForm.MIN_PASSWORD_LENGTH));

The parameter values are all Objects rather than Strings.

Craig