struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Soomar, Muki (R.)" <>
Subject RE: Using a resource file for managing Form errors
Date Thu, 13 Jun 2002 19:54:48 GMT
Seem to be finding my own answers: 
Since I did not find any clear answers in the archives, here is the procedure of doing this

1. Define the Resource bundle in the struts-config.xml file. If you have a resource bundle
by name, then define it as follows:
	<message-resources parameter="com.myDomain.FormErrorResources" />

    a.  The resource bundle is expected to have the extension ".properties" .  If you do not
have this it will not work
    b.  The path to the resource file uses the java package naming convention. So in the above
example, it
         implies that the resource bundle resides in the WEB-INF/classes/com/myDomain/ folder.
         So if you have the resource bundle in the classes folder your parameter value should
be just your
         resource bundle file name minus the .properties extension

2.  If you want to check you have successfully configured it, try the following:
	MessageResource msgRes = servlet.getResources();
	servlet.log (msgRes.getMessage ("key");
        This will log the message corresponding to the key in your log file if you are using

Muki Soomar

-----Original Message-----
From: Soomar, Muki (R.) []
Sent: Thursday, June 13, 2002 3:21 PM
To: Struts-User (E-mail)
Subject: Using a resource file for managing Form errors

I am trying to use a separate resource file for managing errors coming out of the form validation
in an ActionForm. How do I access this resource file? This is a second resource file defined
in my
struts-config.xml file.

Steps taken so far:
1. Defined a Message Resource in the struts-config.xml file as follows:
	<message-resources parameter="com.myDomain.RegistrationFormResources" />

2. Dont have a clue how to utilize this in the ActionForm's Validate method. Tried doing this..

	if ((addressLine_1 == null) || (addressLine_1.length() < 1))
		errors.add("addressLine_1", new ActionError("error.RegistrationForm.addressLine_1.required"));

I checked the archives for finding out the answers, but could not find any.

Any help will be much appreciated.

Muki Soomar

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message