Merrill
Consultant, Sima Solutions
Merrill
Consultant, Sima Solutions
Originally posted by lavi per:
a. If i mention the default resource bundle in web.xml, am i still allowed to specify other resource bundle properties files in struts-config.xml under messages-resource tag. Will struts be able to read all of them (given the correct bundle to read from the request object) ?
Originally posted by lavi per:
Pls. confirm if this is the correct way of retrieving the resource bundle names TEST_1 from Action class as well as ActionForm class
Originally posted by lavi per:
Q - Where is the MessageResources object (resource retrieved from request)i.e TEST_1 being used here ?
Merrill
Consultant, Sima Solutions
Originally posted by lavi per:
In order to specify my module specific resource bundle or any module specific property file (containing key-value information) in addition to the one specified in web.xml (Applicationresources.properties) and then read it in my jsp file using struts html:error or html:messages tags, I should be doing the following
1. In struts-config, add the following
<message-resources key="TEST_1" parameter="com.companyname.test.ApplicationResources1" null="true"/>
<message-resources key="TEST_2" parameter="com.companyname.test.ApplicationResources2" null="false"/>
Please confirm?
Originally posted by lavi per:
2. The properties files as specified in the struts-config file (messages-resource tag) can be kept in any location as long as they available in the classpath.
Please confirm?
Originally posted by lavi per:
3. In ActionForm, in validate method, do either of the following (here i don't need to specify the key (either TEST_1 or TEST_2)
ActionErrors actionErrors = new ActionErrors();
// using ActionError, if you want to display all error messages at the top of the page
actionErrors.add(ActionErrors.GLOBAL_ERROR , new ActionError("error.missing.key");
// using ActionError, if you want to display individual error messages next to the field , where e.g firstName is a property/ field of the ActionForm class
actionErrors.add("firstName", new ActionError("error.missing.key");
//using ActionMessage, if you want to display all error messages at the top of the page
ActionErrors actionErrors = new ActionErrors();
actionErrors.add(ActionMessages.GLOBAL_MESSAGE , new ActionMessage("error.missing.key");
// using ActionMessage if you want to display individual error messages next to the field, where e.g firstName is a property/ field of the ActionForm class
ActionErrors actionErrors = new ActionErrors();
actionErrors.add("firstName" , new ActionMessage("error.missing.key");
Please confirm?
Originally posted by lavi per:
4. In Action class, in execute method, here i don't need to specify the key (either TEST_1 or TEST_2)
ActionErrors actionErrors = new ActionErrors();
// using ActionError, if you want to display all error messages at the top of the page
actionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.missing.key");
// using ActionError, if you want to display individual error messages next to the field , where e.g firstName is a property/ field of the ActionForm class
actionErrors.add("firstName",new ActionError("error.missing.key");
//using ActionMessage, if you want to display all error messages at the top of the page
ActionErrors actionErrors = new ActionErrors();
actionErrors.add(ActionMessages.GLOBAL_MESSAGE , new ActionMessage("error.missing.key");
// using ActionMessage if you want to display individual error messages next to the field, where e.g firstName is a property/ field of the ActionForm class
ActionErrors actionErrors = new ActionErrors();
actionErrors.add("firstName" , new ActionMessage("error.missing.key");
saveErrors(request, actionErrors);
Please confirm?
Originally posted by lavi per:
5. In my java file, if I just want to retrieve the value corresponding to a key from "TEST_1" bundle. Please confirm?
MessageResource resource = (MessageResources) request.getAttribute("TEST_1");
String value = messageResources.getMessage("label.somekey");
Originally posted by lavi per:
6. In my jsp file
a. If I just want to display any message from the property fle
<bean:message bundle="TEST_1" key="some.message.key"/>
Please confirm?
Originally posted by lavi per:
b. If I want to display the error message in the jsp page
Q - ?? how can i specify the resource bundle i.e key="TEST_1" or "TEST_2" here ?? and how do I then display the error messages using both html:error tag as well as html:messages tag.
Merrill
Consultant, Sima Solutions
Merrill
Consultant, Sima Solutions
Merrill
Consultant, Sima Solutions
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|