This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
Similar Threads
struts2: what kicks in first- the interceptors or the form's validation?
Struts2 validation
Struts2 Input Validation using Annotations
Using struts2 only for internationalization
Struts2 - Custom implementation for i18n.