You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ruimo Uno <ru...@gmail.com> on 2007/01/03 12:57:37 UTC

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@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 conversion error message.

Posted by Ruimo Uno <ru...@gmail.com>.
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 <my...@gmail.com>:
> 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" <ru...@gmail.com>
> To: <us...@struts.apache.org>
> 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@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Ruimo Uno
(Shisei Hanai)

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


Re: Struts2 conversion error message.

Posted by Nuwan Chandrasoma <my...@gmail.com>.
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" <ru...@gmail.com>
To: <us...@struts.apache.org>
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@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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