>From Nightly build.
protected void setLocale(HttpServletRequest request, Locale locale) {
HttpSession session = request.getSession();
if (locale == null) {
locale = Locale.getDefault();
}
session.setAttribute(Globals.LOCALE_KEY, locale);
}
Comments on setLocale from Action..
If the locale is null, wouldn't it be better for the default to come from
the request as in request.getLocale(), which is the behavior of the tags
when the Locale at Globals.LOCALE_KEY is not in session scope.
Better Yet. Also if they call setLocale, shouldn't the local object be
non-null. My personal opinion on this stuff is that it should explode with
an illegal argument exception. (I remember a bug report that talked about
Struts quietly handing illegal situations)
if (locale == null) {
throw new java.lang.IllegalArgumentException("Locale was null");
}
As a developer when I misuse an API, I like to see it fail quickly. This way
I don't have to spend a lot of time debugging where I went wrong. Die early
and often in development not during QA or. gulp.. Production!
Rick Hightower
Chief Technology Officer
Trivera Technologies
http://www.triveratech.com
520 290 6855 (Phone)
520 977 8605 (Mobile)