T5 Bean Validation: How to override the property name in validation message?

2011-06-12 Thread 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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5 Bean Validation: How to override the property name in validation message?

2011-06-12 Thread Nillehammer
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



--
http://www.winfonet.eu


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org