I�d like to see Struts play nice with JSTL i18n support.

I have a suggestion along these lines. (This is prelim. I am going to write
some tests and do some prototyping but before I do� I�d like to hear if
there are any thoughts on this).

Currently when you call Action.setLocale you get this:

...class Action...
��� protected void setLocale(HttpServletRequest request, Locale locale) {
�
������� HttpSession session = request.getSession();
������� if (locale == null) {
����������� locale = Locale.getDefault();
������� }
������� session.setAttribute(Globals.LOCALE_KEY, locale);
�
��� }

I am suggesting this (for the release that embraces JSTL�. Struts 1.3 or
1.5).

import javax.servlet.jsp.jstl.core.Config; //get this guy to use its Locale
key as well
...class Action...
��� protected void setLocale(HttpServletRequest request, Locale locale) {
�
������� HttpSession session = request.getSession();
������� if (locale == null) {
����������� locale = Locale.getDefault();//Don�t agree with this, but that
is a different story�
������� }
������� session.setAttribute(Globals.LOCALE_KEY, locale);
                session.setAttribute(Config.FMT_LOCALE, locale); //See
this�. See this�. See this�
��� }

The Config.FMT_LOCALE is similar to the Globals.LOCALE_KEY except that it is
for the JSTL tags, e.g.,

<fmt:message key="title" />

This is one possibility and the one that takes the least amount of effort.
Another possibility is to change all struts i18n tags to use
Config.FMT_LOCALE instead of Globals.LOCALE_KEY, which might be bad because
it would break existing projects.

I am going to write a prototype along these lines in the near future. I need
to test to see if fmt:message will work with Strut�s resource bundles. (I am
not sure it they will or not... I think they will with a little arm
twisting. I am still a little ignorant on the details... I got the big
picture... just not all the details.). Any suggestions from you i18n gurus
would be nice or if someone already started this... clue me in so I don't
waste time.

This could be a first step in getting rid of our good friend bean:message
and replacing him with fmt:message (or at least deprecating him a bit). :(

Don�t worry. I will add this to the Bugzilla feature request as soon as I
test it.

Rick Hightower
Chief Technology Officer
Trivera Technologies
http://www.triveratech.com
520 290 6855 (Phone)
520 977 8605 (Mobile)
�



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to