--- Rick Hightower <[EMAIL PROTECTED]> wrote:
> 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.
What about the situation where you pass in null to clear the Locale from
the session? The method currently assumes that passing null means "use a
default" instead of trusting the user that what they passed in is what
they want in the session. Maybe passing null should mean that any Locale
in the session is to be removed. The saveErrors() and saveMessages()
methods behave that way so it's inconsistent for setLocale() to behave
differently.
Regardless, changing this now would break backwards compatibility but it's
something to think about in 2.x.
David
>
>
>
> 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)
>
>
>
>
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]