File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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 Input Validation using Annotations
Struts2 - Custom implementation for i18n.
Struts2 validation
Using struts2 only for internationalization
struts2: what kicks in first- the interceptors or the form's validation?