You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nillehammer <ta...@winfonet.eu> on 2011/06/12 14:39:25 UTC
T5 Bean Validation: How to override the property name in validation
message?
Hi List,
I have switched from Tapestry's validation API to JSR 303 Bean
Validation API. I have provided a message catalog in
ValidationMessages.properties in the default package. It gets loaded and
the localized error messages are displayed. Only one thing bothers me.
The messages are prepended by the name of the property being validated.
E.g. my bean has a property "getMsg()" that is required. The resulting
error message would be "Msg is required". I'd like to override the "Msg"
part with a more sensible value like "Message" in English or "Nachricht"
in German. How could this be achieved? Would I have to provide a custom
implementation of MessageInterpolator?
I know this question is more related to Bean Validation than to
Tapestry. But maybe someone on this list has encountered the same
problem and can provide a solution for this.
Thanks in advance, nillehammer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5 Bean Validation: How to override the property name in validation
message?
Posted by Nillehammer <ta...@winfonet.eu>.
Answering my own question. The solution turned out to be VERY easy. The
validation message ist constructed by Tapestry's BeanFieldValidator. It
reads the fields label to construct the prefix for the validation
message. That can be customized by putting a "<field-id>-label" into the
message catalog. In my example, I put "msg-label=Message" into my
component's message catalog and now I am satisfied.
Am 12.06.2011 14:39, schrieb Nillehammer:
> Hi List,
>
> I have switched from Tapestry's validation API to JSR 303 Bean
> Validation API. I have provided a message catalog in
> ValidationMessages.properties in the default package. It gets loaded
> and the localized error messages are displayed. Only one thing bothers
> me. The messages are prepended by the name of the property being
> validated. E.g. my bean has a property "getMsg()" that is required.
> The resulting error message would be "Msg is required". I'd like to
> override the "Msg" part with a more sensible value like "Message" in
> English or "Nachricht" in German. How could this be achieved? Would I
> have to provide a custom implementation of MessageInterpolator?
>
> I know this question is more related to Bean Validation than to
> Tapestry. But maybe someone on this list has encountered the same
> problem and can provide a solution for this.
>
> Thanks in advance, nillehammer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
http://www.winfonet.eu
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org