You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Eelco Hillenius (JIRA)" <ji...@apache.org> on 2006/12/08 00:51:22 UTC

[jira] Created: (WICKET-151) set session locale when constructing session object

set session locale when constructing session object
---------------------------------------------------

                 Key: WICKET-151
                 URL: http://issues.apache.org/jira/browse/WICKET-151
             Project: Wicket
          Issue Type: Improvement
    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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eelco Hillenius resolved WICKET-151.
------------------------------------

    Resolution: Fixed

> 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.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457007 ] 
            
Igor Vaynberg commented on WICKET-151:
--------------------------------------

what about when locale changes mid-session. how is that going to be handled? are we going to add final get/setlocale to session so wicket can call setlocale on every request?

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457018 ] 
            
Eelco Hillenius commented on WICKET-151:
----------------------------------------

I've thought about that before - long time ago - as that is something we don't do now either. I don't think we should do this, as code anywhere, anytime could deliberately set the session. If people want to support users changing their locale in the middle of a session by changing their browser settings, imo, that should be done with a custom request cycle. For convenience we could provide such a request cycle, or we could even go so far as to build it in in the standard request cycle and let it depend on a application setting.

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12456723 ] 
            
Johan Compagner commented on WICKET-151:
----------------------------------------

it is simple to implement in 1.3 and 2.0 yes. (not in 1.2.2 because you didn't have the request in newSession())
But i can see the value for this. if somebody really wants to override some locale but it can be set later.
That is currently not really possible or nicely doable.

Because the initialization is also just a call after the creation.

The problem is if we change it how are we going to change it? just add another constructor in WebSession that has an locale
and call that one in newSession(request) ? We can't just delete the default one. Then we break many things (at least for 1.3 i wouldn't do that)



> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464550 ] 

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

Also, we should remove Application#newSession(), which was flaky anyway, as Application also has newSession(Request) already.

> 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

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12456657 ] 
            
Eelco Hillenius commented on WICKET-151:
----------------------------------------

I think it is confusing how it is now. It's not obvious how/ when the locale is set, so the user would have to know that piece of code in WebApplication. But as Wicket does set it (not optional) I think it needs a tighter contract so that it is obvious the locale is provided by the framework right away, gives the user to actually do something with it (now he/ she would have to do that 'lazily') and so that the whole action is kind of atomic.

I agree with making getLocale final btw, and in fact I think I remember final was removed there to make this pinning of the locale possible in the first place.

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457031 ] 
            
Eelco Hillenius commented on WICKET-151:
----------------------------------------

Yeah, we should make them final, but that wasn't really the core issue here. Why my goal was:

public class MyWebSession extends WebSession {

  public MyWebSession(Application application) {
    setLocale(Locale.US);
  }
}

that wouldn't work, as the locale would immediately be overwritten after creation, while I think fixing the locale like this is a lot more obvious and elegant then having to override the getLocale method (which is currently the only way to fix this).

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/WICKET-151?page=all ]

Eelco Hillenius updated WICKET-151:
-----------------------------------

    Component/s: wicket

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464551 ] 

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

erm. not Application#newSession(Request), but WebApplication#newSession(Request) already existed

> 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

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457037 ] 
            
Igor Vaynberg commented on WICKET-151:
--------------------------------------

i guess what i am worried about is this

the way it is now with getlocale overridible and no setter you can implement the usecase you are describing yourself if you wanted to (given request is a param to the session factory like it already is in 2.0?)

but if we create final getter and setter there is no longer a way to pull so we will take flexibility out

now i dont know if this particular usecase needs that much flexibility, so maybe taking it out wont hurt anything

at this point im +0

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12456650 ] 
            
Igor Vaynberg commented on WICKET-151:
--------------------------------------

why make this part of core? it is trivially implemented by the user if it is something they want

if we do this then we cant really leave getlocale overridable because then the two things will clash

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464555 ] 

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

Applied to 1.3 and 2.0 including the auth and examples projects. Still to do is check/ fix the wicket-stuff projects.

> 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

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457039 ] 
            
Eelco Hillenius commented on WICKET-151:
----------------------------------------

Oh, but Session always had a setter. So the current situation is kind of flaky anyway. Not that I don't care much, as I don't think other places where we do this - e.g. isVisible - hurts users in practice.

You can implement the fixed locale now anyway, and you can always get the current request by doing Request.get().

I'm more concerned about what Johan said; it might break a bunch. In that respect I'm ready to drop this again. It's not like I'm looking for more work. I just encountered this as I need to fix the locale for the day project, and I had to think about how I would explain that you can't call setLocale and expect it to work in Wicket In Action. Just ugly if you ask me.

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12462447 ] 

Matej Knopp commented on WICKET-151:
------------------------------------

I don't really care about specifying locale in constructor. I wouldn't mind it either. What i don't really like is having getLocale final. It's not the wicket way. 

> 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

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ 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

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457053 ] 
            
Johan Compagner commented on WICKET-151:
----------------------------------------

the use case i see is a bit different.
There are users wants to have a fixed locale and not one from the default request
But that again can be overridden by preferences or something mid session.

This is very hard to do currently.

You can't do it in the constructor because we will override it again with setLocale
and when we call setLocale after construction they don't know that that is a call they don't want (locale from the request)
So for this case you have to override setLocale (that is then a NOP)
and introduce a setLocaleThatSticks method that they call them selfs.

Thats why i am still +1 (or is it +0.5 :) for us supplying the locale in the constructor.
But i think supplying the Request in the constructor is maybe even better..
Then they can configure there session exactly as the want. (ofcourse they can already do that outside of the session (ISessionFactory)
But maybe doing that inside the session you have more control (private fields setting and so on)
And we do then in the base session class:

setLocale(request.getLocale())

Then we set it once and then they can configure it like they want. 

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-151) set session locale when constructing session object

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-151?page=comments#action_12457020 ] 
            
Igor Vaynberg commented on WICKET-151:
--------------------------------------

so then you agree we need final getlocale/setlocale, so why even have a constructor arg? just call setlocale when the session is created?

> set session locale when constructing session object
> ---------------------------------------------------
>
>                 Key: WICKET-151
>                 URL: http://issues.apache.org/jira/browse/WICKET-151
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 2.0, 1.3
>            Reporter: Eelco Hillenius
>         Assigned To: Eelco Hillenius
>             Fix For: 2.0, 1.3
>
>
> 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira