Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Struts2 conversion error message.

Ruimo Uno

2007-01-03

Replies:

Hi, Nuwan,

Thanks for quick reply.
Yes, I know this tech for validator. I saw this in 'WebWork in Action" before.
However, it seems the 'fieldName' property cannot observable for
conversion error. If you make the message something like this:

xwork.default.invalid.fieldvalue = Invalid field value for field
${getText(fieldName)}.

Struts reports an exception:

java.lang.IllegalArgumentException: can't parse argument number
getText(fieldName)

  java.text.MessageFormat.makeFormat (MessageFormat.java:1339)
  java.text.MessageFormat.applyPattern (MessageFormat.java:458)
  java.text.MessageFormat.(MessageFormat.java:350)

Any suggestion?

2007/1/4, Nuwan Chandrasoma <mymailnot@(protected)>:
> Hi,
>
> Yes it is possible . take a look at this tutorial
>
> http://struts.apache.org/2.x/docs/localizing-output.html
>
> Thansks,
>
> Nuwan.
>
>
> ----- Original Message -----
> From: "Ruimo Uno" <ruimo.uno@(protected)>
> To: <user@(protected)>
> Sent: Wednesday, January 03, 2007 11:57 AM
> Subject: Struts2 conversion error message.
>
>
> > Hi,
> >
> > I'm evaluating Struts-2.0.1.
> >
> > The default error message for conversion error is
> > 'xwork.default.invalid.fieldvalue' and it shows something like the
> > following message:
> >
> > Invalid field value for field "user.age".
> >
> > But the 'user.age' is confusing for end users. Moreover, it is
> > difficult to undestand for non-native people. Of course, you can
> > override the message by preparing error message for each field:
> >
> > invalid.fieldvalue.user.age = Age is invalid.
> >
> > But in this manner, the message explodes because it requires message by
> > field.
> >
> > invalid.fieldvalue.user.name = User name is invalid.
> > invalid.fieldvalue.user.age = Age is invalid.
> > ...
> >
> > So, my question is "Is it possible to access the field name from
> > message file?" I want to construct the message something like this:
> >
> > xwork.default.invalid.fieldvalue = Invalid field value for field
> > "${getText(fieldName)}".
> > user.age = Age
> > user.name = User name
> >
> > Thanks,
> >
> > --
> > Ruimo Uno
> > (Shisei Hanai)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


--
Ruimo Uno
(Shisei Hanai)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.