• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts Validator Message Arguments

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's great that I can compose validation failure messages using a resource properties file, passing in different resource keys as arguments like so:

<field property="fieldname" depends="required">
<msg name="reqmsg" key="form.add.errors.fieldname.required" />
<arg0 key="form.fieldname.display" />
</field>

..Which has a properties resource that results in the message:

<span class="error-field">Field Name</span> is required.

So, what if I want to use a runtime value as a message argument? Is that possible with the Struts Validator? How is it accomplished? For example, my target message would be something like:

The <span class="error-field">Username</span> <span class="error-value">root</span> is already taken by another user. Please choose a different <span class="error-field">Username</span>.

... The message properties would look something like:

user.add.errors.username.taken=The <span class="error-field">{0}</span> <span class="error-value">{1}</span> is already taken by another user. Please choose a different <span class="error-field">{0}</span>.

But, I can't find any documentation on how to configure validation.xml to pass the argument in from a FormBean property. Am I chasing my tail, or is this possible?

Thanks,

Dan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic