| Author |
Struts2 : How to Create Parameterized i18n Message with an Annotation
|
Sakthi Priya
Greenhorn
Joined: Apr 02, 2009
Posts: 26
|
|
// class file annotation snippet
@EmailValidator(message = "", key = "validation.login.invalid.email")
// resource bundle .properties file snippet
validation.login.invalid.email = You have provided an invalid email address.
This, of course, takes the i18n message in a pre-defined properties file for the error string that ultimately gets produced when the validation fails - which happens to work like a charm. However I want to be able to parameterize the message;
// DESIRED resource bundle .properties file snippet
validation.login.invalid.email = {0} is not a valid email address.
The idea is to produce the following actionError string;
'bad@emailaddress' is not a valid email address
Can someone tell me what the correct annotation syntax would be to accomplish this? Struts2 provides fairly comprehensive XML validation support and configuring this via that mechanism is in fact straight forward - but for other reasons I'm trying to avoid that implementation - I would like to stick entirely to annotations for input validation if possible.
|
 |
 |
|
|
subject: Struts2 : How to Create Parameterized i18n Message with an Annotation
|
|
|