This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 : How to Create Parameterized i18n Message with an Annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 : How to Create Parameterized i18n Message with an Annotation" Watch "Struts2 : How to Create Parameterized i18n Message with an Annotation" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 : How to Create Parameterized i18n Message with an Annotation