See the Javadoc for Action. To get the resource bundle from your action:
http://struts.apache.org/api/org/apache/struts/action/Action.html#getResources(javax.servlet.http.HttpServletRequest)
You then have various options for retrieving specific messages:
http://struts.apache.org/api/org/apache/struts/util/MessageResources.html
L.
Ashutosh Satyam wrote:
Hi,
In my application I want to set the error key based on whether
the error key is present in resource bundle. The error key is
generated in the system and the top most layer 'Action class' is
supposed to set the keys based on the error key availability.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sample/Pseudo code demonstrating what I exactly tend to do.
String key = null;
String[] param = null;
ResourceBundle bundle = getBudle();
if("a.b.c.d".isPresent(bundle))
key = "a.b.c.d";
param = new String[2]
param[0]="s1";
param[1]="s2;
elseif("a.b.c."isPresent(bundle))
key = "a.b.c";
elseif("a.b".isPresent(bundle))
key="a.b";
elseif("a".isPresent(bundle))
key = "a"
else
key = "default.errorkey";
ActionErrors errors = new ActionErrors();
If(param != null)
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError(key,params));
else
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError(key,params));
saveErrors(req,errors);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Is there a handle available through Struts framework to read Resource Bundle
so that I can look whether a particular key is present or not and accordingly
construct ActionError.
Any pointers on this will be appreciated.
Thansk & Regards,
Ashutosh
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]