File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes @RequiredFieldValidator & i18n 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 "@RequiredFieldValidator & i18n" Watch "@RequiredFieldValidator & i18n" New topic

@RequiredFieldValidator & i18n

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
I have a simple required field validator in an action and it validates the field as it should. I cant figure out how to get i18n messages returned through.

properties file contains:
username.requiredString = User Name is a required field.

Action has:

When I do action validation "username.requiredString" is returned as the error message from the properties file. I have also tried OGNL in the message=%{username.requiredString} but a literal is always returned instead of the string from the properties file. I bet I have tried this 8 different ways and I cant get the message from the properties file.

If I use XML validation the string from the properties file comes back fine.


E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
I was able to get this working by removing the message and adding a key. The key is then pulled from the properties file as I would expect. This seems to work fine.

I agree. Here's the link:
subject: @RequiredFieldValidator & i18n
Similar Threads
S2: How to perform Date validation with notation?
struts2 validate a checkbox
Struts 2.1.8 validation.xml & internationalization
struts2 validation with conditions!
validation annotation in struts-2