You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2014/02/12 01:59:41 UTC

DateTool and locale setting

All,

Umm... I probably should have noticed this long before today, but I just
observed a problem with my configuration and I wanted to make sure that
my (new) understanding of the DateTool is correct.

So, I had DateTool configured to be an "application" level tool. That
appears to have been a mistake.

What I just observed is that the first user to trigger the creation of
the DateTool tool ends up permanently-setting the locale for the tool to
their preferred locale. Whoops.

So the solution should be simply to change the "scope" of the tool from
application to session, right?

I should have realized that DateTool wasn't tied to the servlet API in
any way, so sniffing the locale from the request (which is what I
expected) is not really a possibility. Duh.

Thanks,
-chris


Re: DateTool and locale setting

Posted by Claude Brisson <cl...@renegat.net>.
It all depends on what you wants. If you really want the DateTool to
follow the user locale, then must use the session scope. Otherwise, you
can keep it in the application scope, and add a 'locale' property:


  <toolbox scope="application">
    <tool key="date"
          class="org.apache.velocity.tools.generic.ComparisonDateTool"
          locale="en_US"/>
  </toolbox>


  Claude

On Tue, 11 Feb 2014 19:59:41 -0500
Christopher Schultz <ch...@christopherschultz.net> wrote:

> All,
> 
> Umm... I probably should have noticed this long before today, but I
> just observed a problem with my configuration and I wanted to make
> sure that my (new) understanding of the DateTool is correct.
> 
> So, I had DateTool configured to be an "application" level tool. That
> appears to have been a mistake.
> 
> What I just observed is that the first user to trigger the creation of
> the DateTool tool ends up permanently-setting the locale for the tool
> to their preferred locale. Whoops.
> 
> So the solution should be simply to change the "scope" of the tool
> from application to session, right?
> 
> I should have realized that DateTool wasn't tied to the servlet API in
> any way, so sniffing the locale from the request (which is what I
> expected) is not really a possibility. Duh.
> 
> Thanks,
> -chris
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org