• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Struts2 : How to Create Parameterized i18n Message with an Annotation

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
// 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.
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic