You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by gd...@cmhc-schl.gc.ca on 2004/07/05 17:23:12 UTC
Message Resources Confusion
Greetings,
I am somewhat unclear with the Message Resources.
I have defined in my struts-config:
<message-resources parameter="app.resources.ApplicationResources"/>
<message-resources parameter="app.resources.SystemErrors"
key="systemErrors"/>
In my Action class I have the following code:
if (getSPName() == null) {
MessageResources errorMessages = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);
String errorMessage =
errorMessages.getMessage("errors.invalid.SPName");
logger.error(errorMessage);
errors.add(ActionErrors.GLOBAL_MESSAGE, new
ActionMessage("errors.9000"));
saveErrors(request, errors);
return
mapping.findForward(errorMessages.getMessage("forward.systemError"));
}
Question 1:
Does the request.getAttribute(Globals.MESSAGES_KEY) load the keys of both
resources found in the struts-config?
The message with the key ("errors.invalid.SPName") returns a null.
Question 2:
If I code it this way the message found.
MessageResources errorMessages = this.getResources(request,
"systemErrors");
Any help explaining this is appreciated.
TIA,
Glenn
Re: Message Resources Confusion
Posted by Henrique VIECILI <vi...@softplan.com.br>.
The answer is, (someone correct me if i am wrong!)
No, Globals.MESSAGES_KEY key only holds the default MessageResources. If you look you will find an attribute named 'systemErrors' wich contains the MessageResources object of app.resources.SystemErrors
And if you use this bundle for error messages, notice the use of bundle in <html:errors>
<html:errors bundle="systemErrors"/>
Henrique Viecili
----- Original Message -----
From: gdeschen@cmhc-schl.gc.ca
To: user@struts.apache.org
Sent: Monday, July 05, 2004 12:23 PM
Subject: Message Resources Confusion
Greetings,
I am somewhat unclear with the Message Resources.
I have defined in my struts-config:
<message-resources parameter="app.resources.ApplicationResources"/>
<message-resources parameter="app.resources.SystemErrors"
key="systemErrors"/>
In my Action class I have the following code:
if (getSPName() == null) {
MessageResources errorMessages = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);
String errorMessage =
errorMessages.getMessage("errors.invalid.SPName");
logger.error(errorMessage);
errors.add(ActionErrors.GLOBAL_MESSAGE, new
ActionMessage("errors.9000"));
saveErrors(request, errors);
return
mapping.findForward(errorMessages.getMessage("forward.systemError"));
}
Question 1:
Does the request.getAttribute(Globals.MESSAGES_KEY) load the keys of both
resources found in the struts-config?
The message with the key ("errors.invalid.SPName") returns a null.
Question 2:
If I code it this way the message found.
MessageResources errorMessages = this.getResources(request,
"systemErrors");
Any help explaining this is appreciated.
TIA,
Glenn