Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts framework not peeking up my Locale propertis files

 
Cippi Patil
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using struts 1.3 in my application and also using validation plugin of the same version.
I have placed my applicationResources.properties file in some folder.
My project(web site) is peeking up the keys for English locale but when i placed my locale specific applicationResources_es_CO.properties file in the same folder its not showing up on the UI. Instead i am getting fillowing warning on console.

org.apache.commons.validator.ValidatorResources getForm 'DesclaimerEntryForm' Form not found for locale 'en_US'

org.apache.commons.validator.ValidatorResources getForm 'DesclaimerEntryForm' Form not found for locale 'es_CO'

I am not getting the reason and not able find out the solution.
Please help me out as my client is form Colombia and he focusing more on colombain locale rather English locale.
 
mike cleveland
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For future reference to others...

I support an existing application and we've been working to upgrade to struts 1.3.10. This app has been running several years. I had never seen this warning message until the upgrade attempt, and it's only appearing for a few pages. Due to multiple issues, we've trying to run down all possibilities and this warning was one of them. Here's what I found to be causing this warning.

Most of the suggestions I had found talked about ensuring that all Forms that required validation be included in the validation.xml file as a <form> element, even if it is jsut an empty element. If the relevant <form> element can't be located, you get the warning. Well, my validation.xml had all the relevant <form> entries, so the solution is the same idea, but instead of the <form element not being there, the validation was looking for it using the wrong key value for the couple pages where I had the warning.

Most of the app's Form classes (myForm.java) are extending org.apache.struts.validator.ValidatorForm, but a couple (the ones generating the warning) extend org.apache.struts.validator.ValidatorActionForm (which itself extends ValidatorForm). In reviewing the API docs for both classes, there is a subtle difference in the key value that is retrieved from the <action> element of struts-config.xml. One class retrieves the 'path' attribute, the other the 'name' attribute. This key value is then used to locate the relevant <form> element in validation.xml, per the element's 'name' attribute.

Once I changed the couple Form classes to use ValidatorForm, the proper key value was retrieved which matched to the entries in validation.xml and the warning message went away.

For reference...
http://struts.apache.org/release/1.2.x/api/org/apache/struts/validator/ValidatorForm.html
https://struts.apache.org/release/1.3.x/struts-extras/apidocs/org/apache/struts/validator/ValidatorActionForm.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic