From: "Zhang, Larry (L.)" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: RE: How to access a variable message resource bundle from JSP Date: Fri, 14 May 2004 12:01:42 -0400
Suppose you have
<% String countryCode = "en"; %>
I think <bean:message key="yourPropertyKey" bundle="<%=countryCode%>"> will do your work.
Another way is that you save your Locale object to session in jsp something like
session.setAttribute(Globals.LOCALE_KEY, yourLocaleObject);
then Struts can just find out the correct resource for different locale when you use the following in the jsp <bean:message key="yourPropertyKey">
Hope this helps.
Larry Zhang
-----Original Message----- From: None None [mailto:[EMAIL PROTECTED] Sent: Friday, May 14, 2004 11:40 AM To: [EMAIL PROTECTED] Subject: How to access a variable message resource bundle from JSP
Hi again everyone... yesterday, with assistance from some of you folks, I was able to get multiple message resource bundles working to return a Locale-specific error message from one of my Action classes. Very cool.
Now I'm trying to do the same thing in a JSP.
Here's my question... in my JSP's, when using <bean:message>, I know that I
can specify bundle="en" or bundle="de" and that works, since I have a
properties file set up for English and German. But how can I set the bundle
attribute to a variable value?
In other words, at present I have String in session called countryCode, and
it's literally the value EN, DE, or whatever else. So, is there a way I can
plug that string into the <bean:message> tag's bundle attribute?
Or, is there another method of specifying which of a number of message resource bundle to look in for a specific key that can be varied programmatically? Or further still, is there specifically a special method to get locale-specific string in a JSP tag, as I am now able to do in my Action classes?
Thanks all!
_________________________________________________________________ MSN Toolbar provides one-click access to Hotmail from any Web page - FREE download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Express yourself with the new version of MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]