wood burning stoves 2.0*
The moose likes Struts and the fly likes Need Help in accesing the bundle / key value in action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Need Help in accesing the bundle / key value in action class" Watch "Need Help in accesing the bundle / key value in action class" New topic
Author

Need Help in accesing the bundle / key value in action class

rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Hi All,

The following two lines are in strutsconfig.xml
one for english and one or welsh language

<message-resources parameter="com.ips.ApplicationResources" null="false"/>
<message-resources parameter="com.ips.ApplicationResources_cy" key="welsh" null="false" />

in my jsp
its for welsh
<label class="error" id="titleerror">
<bean:message bundle="welsh" key="errors.title.required" />
</label>


for english
<label class="error" id="titleerror">
<bean:message key="errors.title.required" />
</label>

i want to access the value of keyattribute of message-resource of struts-config.xml in my action class or the value of bundle attribute of bean:message tag in my action class?

can you suggest me the options?

Thanks
Rajesh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

A couple of seconds on Google returned a first page full of examples. Try searching for "struts +access message bundle in action" or something similar.
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
I tried googling its no worthful to meet my requirement.

suggest me some ideas
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't really know what your requirement is.

What, specifically, are you trying to do? Normally the locale is set by the user's browser, or over-ridden by a session variable (as when the user wants to use a specific language no matter what the browser provides).
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Hi David,
Actually is there any option to set the Locale in jsp?
for welsh i want to set locale as cy and want to get that value in my action class?
will it be possible?

Thanks
Rajesh
Mudit Srivastava
Ranch Hand

Joined: Apr 30, 2007
Posts: 38
you can give a drop down with a key-value pair, containing the Locale ID as the key and name of the language as the value. Upon selecting the language, the key can be passed back to the action class, which you can set in your session.
 
 
subject: Need Help in accesing the bundle / key value in action class
 
Similar Threads
unable to use more than 2 <bean:message. tags in jsp
i have a requirement in struts, need to use 2 properties file for two jsp's?
Message resources and struts modules
How to access a (non default) resource bundle from .jsp
I want to access the value of keyattribute of message-resource of struts-config.xml in my action