[ 
https://issues.apache.org/jira/browse/WICKET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464549
 ] 

Eelco Hillenius commented on WICKET-151:
----------------------------------------

I'd like to go for Johan's idea of passing in the current request. RequestCycle 
is not yet constructed, so we can't get the Request through that.

Currently, IApplicationSettings#getDefaultLocale is used, which by default 
returns the server's locale (Locale.getDefault()). Besides the fact that this 
always effectively has been a noop as it is immediately overwritten by that 
setLocale call, this 'setting' should go for several reasons:
* if people REALLY want to work with a server locale, they can use 
Locale#getDefault and Locale#setDefault by themselves.
* using Locale#getDefault not only is questionable for it's usability, it is 
also dangerous as you might run into different behavior just by deploying on 
another server.
* even though the setting has been in there for a long time, it wasn't used 
anywhere else (except for being printed in the application view).
* it's much better to 'fix' the locale for Wicket by overriding getLocale or - 
after the change - setting it in the constructor.

I'm keeping with Matej's remark to not make it final. It *is* tighter to make 
it final (and in that sense, it would have my preference), but imo not really 
something that wreaks havoc; if people want to do it that way, fine by me.

So, I'm proposing:
* pass in the current Request object in the session's constructor.
* do NOT call setLocale right after the session was created (see 
WebApplication#getSession), but rather set the locale using the passed in 
Request argument.
* get rid of IApplicationSettings#getDefaultLocale


> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: https://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3, 2.0
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 1.3, 2.0
>
>
> Currently, we create the session objects like this:
> WebApplication#getSession:
> if (session == null)
> {
>       // Create session using session factory
>       session = getSessionFactory().newSession(request);
>       // Set the client Locale for this session
>       session.setLocale(request.getLocale());
> What I propose is to change the constructor from Session/ WebSession to take 
> in a Locale parameter as well. That would make it possible for custom session 
> classes to fix the locale by setting it in the constructor. Now that is only 
> possible by overriding Session#getLocale

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to