You forgot to cast to Object[]
return getMessages().format(key, (Object[])arg);
Also,
return getMessages().format(key, new Object[] { arg });
can become
return getMessages().format(key, arg );
>From Matt Raible <[EMAIL PROTECTED]>:
> I have the following in a base class for my Tapestry pages to extend:
>
> protected String getText(String key, Object arg) {
> if (arg == null) {
> return getText(key);
> }
>
> if (arg instanceof String) {
> return getMessages().format(key, new Object[] { arg });
> } else if (arg instanceof Object[]) {
> return getMessages().format(key, arg);
> } else {
> log.error("argument '" + arg + "' not String or Object[]");
>
> return "";
> }
> }
>
> Passing in a key, or a single String argument works fine:
>
> getText("user.added", user.getFullName());
>
> However, if I pass in an Object array, the substituted values get garbled:
>
> getText("login.passwordHint.sent", new Object[] {username, user.getEmail()})
>
> login.passwordHint.sent=The password hint for <strong>{0}</strong> has
> been sent to <strong>{1}</strong>.
>
> Results in:
>
> The password hint for <strong>[Ljava.lang.Object;@1ce1387</strong> has
> been sent to <strong>{1}</strong>.
>
> Any ideas?
>
> Thanks,
>
> Matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]