Eng_Resources.properties file is placed in the /WEB-INF/classes/ directory
validate.FirstName.incomplete=<LI>Please input your first name.</LI> validate.LastName.incomplete=<LI>Please input your last name.</LI> validate.Address.incomplete=<LI>Please input your Address.</LI> validate.Phone.incomplete=<LI>Please input your Phone.</LI> validate.Email.incomplete=<LI>Please input a valid email address.</LI>
The "???XXX???" messages appear because Struts couldnt find the appropriate propertie file.
As far as I know, in the "message-resources" tag, the option "parameter" indicate in which package the resource will be found.
So, you dont need to specify "/WEB-INF/classes/" here.
For exemple, just type parameter="Eng_Resources" to indicate that you want Struts to search for the prop file in the root directory of your classes which is your /WEB-INF/classes/ directory by default.
Or type parameter="my.package.Eng_Resources" if you prefer that Struts search for the Eng_Resources.propertie file in the package you want which is /WEB-INF/classes/my/package/ directory.
Try renaming your message resources file ApplicationResources_en_US.properties or simply ApplicationResources.properties, and changing the entry in the <message-resources> tag in the struts-config file. These file names are expected to follow a standard naming convention with <language code>_<country code> appended to the end of the file name before it's extension. If you're not using internationalization features, it's best just to leave it at the default name, which is ApplicationResources.properties.
I don't think the naming of the resource is the problem... i tried everything that was suggested but none of it's working... why is it that the resource that i am trying to access i.e. validate.Address.incomplete is prefaced by en_US when it is printed out?... is there something that has to be set in the web.xml file that i'm missing (i.e. an init parameter that specifies the existance of resources?) or is it because i am using the ActionErrors GLOBAL_MESSAGE as the key when i'm populating in the ActionForm... the following is the web.xml file that i'm using...
once again thanks for your time but i think it lies somewhere other then the naming of the resource.
are you setting your locale explicitly in your code? the locale may be incorrectly set (e.g using locale instead of language locale or vice versa).
you are also missing <html:html locale="true"> on the top of your jsp if you are doing multiple resource files for multiple languages. this html:html tag generates the 'lang' attribute that is required for struts to locate the proper resource file.
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
I'm not trying to do multiple resources based on locale but it appears that the resource key that it is trying to find is en_US.validate.FirstName.incomplete when the resource that i'm calling is simply validate.FirstName.incompleteb (why is it prefacing it)... i've put it in ApplicationResources and ApplicationResources_en_US properties files, i've prefaced the key=value pairs in the resource file with en_US. to see if they'll match... i just added the locale key that you mentioned and still the same bloody error messages... this is making me absolutely nuts...
do i have to do more then simply start and stop the local tomcat server? does it have anything to do with the fact that i am using the ActionErrors GLOBAL_MESSAGE value as the key for all my values?
I've put the following in my servlet parameters in web.xml
*********************************************************************** why can't we just state everything in a bloody java class... at least the errors would give me something to track down i'm praying for a null pointer exception right now [ May 23, 2005: Message edited by: Billy Bob ]
If you get the same message before you even try to submit the form, then you know for sure that struts can't find your message resource, and that the problem has nothing to do with your validate() method.
If you will do exactly the following, I believe it will solve your problem:
Rename the file as I previously suggested
Put the properties file in a package (directory structure) all by itself. Any package name will do (e.g. com.myCompany.myapp.resources) and make sure that directory structure exists in your /WEB-INF/classes directory
In your struts-config.xml file <message-resourcs parameter="com.myCompany.myapplication.resources.ApplicationResources" />
[ May 23, 2005: Message edited by: Merrill Higginson ]
i did get the same message before i submitted but again changing the directory and file name didn't change it... i do truly appreciate everyones time and if someone has another 15min to spare you can download a zip of the directory i'm using at www.andymellett.com/strutsTests.zip ... this has been driving me nuts for a couple of days and i'm sure its something small, mind you it could also be the tomcat version i'm using, or some config issue in there who knows... if you would care to take a look at the files and let me know what you think i'd appreciate it... do note that i haven't coded anything in the Action simply because it was the form validation using the ActionForm that i was trying out.
thanks again for your time [ May 23, 2005: Message edited by: Billy Bob ]
Welcome to JavaRanch. We don't have many rules here, but we do have a naming policy which we try to strictly enforce. Please re-read this document and edit your display name in order to comply. Thanks in advance, and we look forward to seeing you around the Ranch.
I downloaded your zip file, and was able to get it working by doing the following:
The ApplicationResources_en_US.properties file you sent was a binary object my text editor couldn't read. It should be a simple text file, not a compiled Properties object. I created a new text file named ApplicationResources_en_US.properties and added the messages from your first posting.
In the struts-config.xml file, I changed the messages-resources entry to: <message-resources parameter="com.andymellett.resources.ApplicationResources_en_US" null="false"/>
In the validate() method of InfoForm, I changed all references of ActionMessage to ActionError
Try doing these things with your application, and see if it works
bloody hell... i could open that file with whatever i wanted, notepad, wordpad, etc... i must have accidentally saved it as unicode when i created it... i hate stuff like that ... all i had to do was recreate that file... thanks so much for your help and time...
fyi as of struts 1.2 ActionError has been depreciated and as i understand it they will be removing it in 1.3...
thanks again so much... i was wondering why i was going crazy
Hi, I am not sure whether my reply will help you.Still let me give a try. Basically in a struts application we will have a basic messageResources property file, say ApplicationResources.properties . In you struts-config.xml you have to map this into your struts-config.xml file as <message-resources parameter="ApplicationResources.properties"/> If there is any package structure for the property file say "org.resources.ApplicationResources" then the mapping will be as follows <message-resources parameter="org.resources.ApplicationResoures"/> When you handle locale for internationalization, set the locale and provide corresponding property file in the same location of the default one with the corresponding language and country code as ApplicationResources_en_US.properties( for language english and country US) In your JSP you have to set <html:html locale="true">.
Hope this will help you. You can check ResourceBundle class of Java and MessageResources class of Struts for your further reference.
All the best
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop