Re: localization and session expiration

2009-03-06 Thread Leszek Gawron

Anton Veretennikov wrote:

May be cookie?


You can also try to extract the locale used by user in the browser from 
request header:



http://www.acegisecurity.org/guide/springsecurity.html#concurrent-sessions

GET /guide/springsecurity.html HTTP/1.1
Host: www.acegisecurity.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) 
Gecko/2009011913 Firefox/3.0.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pl,en;q=0.7,en-us;q=0.3

   ^

Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.acooke.org/cute/SessionLim0.html
If-Modified-Since: Tue, 15 Apr 2008 17:18:26 GMT
If-None-Match: 28002-5ba09-44aec96961c80
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified
Date: Fri, 06 Mar 2009 11:52:59 GMT
Server: Apache/2.2.8 (EL)
Connection: close
Etag: 28002-5ba09-44aec96961c80


Spring can resolve locale for you in a flexible manner:

http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/LocaleResolver.html

in your case:

http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.html

To integrate wicket with spring in this context override 
WebApplication.newSession:


@Override
public Session newSession( Request request, Response response ) {
return new WebSession( request ) {
@Override
public Locale getLocale() {
return LocaleContextHolder.getLocale();
}
};
}


--
Leszek Gawron

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: localization and session expiration

2009-03-06 Thread Jonas
No need to use spring for that, the locale of a WebSession is
initialized from ServletRequest#getLocale()
by default, which is based on the Accept-Language header.

On Fri, Mar 6, 2009 at 12:57 PM, Leszek Gawron lgaw...@apache.org wrote:
 Anton Veretennikov wrote:

 May be cookie?

 You can also try to extract the locale used by user in the browser from
 request header:

 http://www.acegisecurity.org/guide/springsecurity.html#concurrent-sessions

 GET /guide/springsecurity.html HTTP/1.1
 Host: www.acegisecurity.org
 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6)
 Gecko/2009011913 Firefox/3.0.6
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Accept-Language: pl,en;q=0.7,en-us;q=0.3

                   ^

 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer: http://www.acooke.org/cute/SessionLim0.html
 If-Modified-Since: Tue, 15 Apr 2008 17:18:26 GMT
 If-None-Match: 28002-5ba09-44aec96961c80
 Cache-Control: max-age=0

 HTTP/1.x 304 Not Modified
 Date: Fri, 06 Mar 2009 11:52:59 GMT
 Server: Apache/2.2.8 (EL)
 Connection: close
 Etag: 28002-5ba09-44aec96961c80

 Spring can resolve locale for you in a flexible manner:

 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/LocaleResolver.html

 in your case:

 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.html

 To integrate wicket with spring in this context override
 WebApplication.newSession:

 @Override
 public Session newSession( Request request, Response response ) {
        return new WebSession( request ) {
               �...@override
                public Locale getLocale() {
                        return LocaleContextHolder.getLocale();
                }
        };
 }


 --
 Leszek Gawron

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: localization and session expiration

2009-03-06 Thread Anton Veretennikov
If cookie is already set, get it and use, if no then set it as browser's
getLocale() and save to cookie.

To get cookies:

Cookie[] cookies =
((WebRequest)getRequestCycle().getRequest()).getCookies();
if (cookies!=null) {
for (int i = 0; i  cookies.length; i++) {
  Cookie cookie = cookies[i];
  ...
}
}

To set cookie:

Cookie cookie = new Cookie(language, selectedLanguage);
cookie.setMaxAge(2678400); //31 день
((WebResponse) getRequestCycle().getResponse()).addCookie(cookie);

-- Tony

On Fri, Mar 6, 2009 at 7:26 PM, Jonas barney...@gmail.com wrote:

 No need to use spring for that, the locale of a WebSession is
 initialized from ServletRequest#getLocale()
 by default, which is based on the Accept-Language header.

 On Fri, Mar 6, 2009 at 12:57 PM, Leszek Gawron lgaw...@apache.org wrote:
  Anton Veretennikov wrote:
 
  May be cookie?
 
  You can also try to extract the locale used by user in the browser from
  request header:
 
 
 http://www.acegisecurity.org/guide/springsecurity.html#concurrent-sessions
 
  GET /guide/springsecurity.html HTTP/1.1
  Host: www.acegisecurity.org
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6)
  Gecko/2009011913 Firefox/3.0.6
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: pl,en;q=0.7,en-us;q=0.3
 
^
 
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 300
  Connection: keep-alive
  Referer: http://www.acooke.org/cute/SessionLim0.html
  If-Modified-Since: Tue, 15 Apr 2008 17:18:26 GMT
  If-None-Match: 28002-5ba09-44aec96961c80
  Cache-Control: max-age=0
 
  HTTP/1.x 304 Not Modified
  Date: Fri, 06 Mar 2009 11:52:59 GMT
  Server: Apache/2.2.8 (EL)
  Connection: close
  Etag: 28002-5ba09-44aec96961c80
 
  Spring can resolve locale for you in a flexible manner:
 
 
 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/LocaleResolver.html
 
  in your case:
 
 
 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.html
 
  To integrate wicket with spring in this context override
  WebApplication.newSession:
 
  @Override
  public Session newSession( Request request, Response response ) {
 return new WebSession( request ) {
 @Override
 public Locale getLocale() {
 return LocaleContextHolder.getLocale();
 }
 };
  }
 
 
  --
  Leszek Gawron
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: localization and session expiration

2009-03-06 Thread ElSe

Thanks for your answers! It is quite good idea with cookies and header...
Unfortunately it will not work if the user turns off cookies in his
browser... but I think in this case he can thank himself for such
inconvenience :

BR,
Elena.


Anton Veretennikov wrote:
 
 If cookie is already set, get it and use, if no then set it as browser's
 getLocale() and save to cookie.
 
 To get cookies:
 
 Cookie[] cookies =
 ((WebRequest)getRequestCycle().getRequest()).getCookies();
 if (cookies!=null) {
 for (int i = 0; i  cookies.length; i++) {
   Cookie cookie = cookies[i];
   ...
 }
 }
 
 To set cookie:
 
 Cookie cookie = new Cookie(language, selectedLanguage);
 cookie.setMaxAge(2678400); //31 день
 ((WebResponse) getRequestCycle().getResponse()).addCookie(cookie);
 
 -- Tony
 
 On Fri, Mar 6, 2009 at 7:26 PM, Jonas barney...@gmail.com wrote:
 
 No need to use spring for that, the locale of a WebSession is
 initialized from ServletRequest#getLocale()
 by default, which is based on the Accept-Language header.

 On Fri, Mar 6, 2009 at 12:57 PM, Leszek Gawron lgaw...@apache.org
 wrote:
  Anton Veretennikov wrote:
 
  May be cookie?
 
  You can also try to extract the locale used by user in the browser from
  request header:
 
 
 http://www.acegisecurity.org/guide/springsecurity.html#concurrent-sessions
 
  GET /guide/springsecurity.html HTTP/1.1
  Host: www.acegisecurity.org
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
 rv:1.9.0.6)
  Gecko/2009011913 Firefox/3.0.6
  Accept:
 text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: pl,en;q=0.7,en-us;q=0.3
 
^
 
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 300
  Connection: keep-alive
  Referer: http://www.acooke.org/cute/SessionLim0.html
  If-Modified-Since: Tue, 15 Apr 2008 17:18:26 GMT
  If-None-Match: 28002-5ba09-44aec96961c80
  Cache-Control: max-age=0
 
  HTTP/1.x 304 Not Modified
  Date: Fri, 06 Mar 2009 11:52:59 GMT
  Server: Apache/2.2.8 (EL)
  Connection: close
  Etag: 28002-5ba09-44aec96961c80
 
  Spring can resolve locale for you in a flexible manner:
 
 
 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/LocaleResolver.html
 
  in your case:
 
 
 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.html
 
  To integrate wicket with spring in this context override
  WebApplication.newSession:
 
  @Override
  public Session newSession( Request request, Response response ) {
 return new WebSession( request ) {
 @Override
 public Locale getLocale() {
 return LocaleContextHolder.getLocale();
 }
 };
  }
 
 
  --
  Leszek Gawron
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 
 

-- 
View this message in context: 
http://www.nabble.com/localization-and-session-expiration-tp22366384p22384529.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



localization and session expiration

2009-03-05 Thread ElSe

Hello!

I have a question: in my application there are several locales and the user
can choose locale on the fly. Locale is stored in the session and all is ok
while the session exists. But! When the session is expired the application
must say user about this and it does - using default locale. It is
unpleasant - from the user's point of view the application changes locale by
its own will. Is there any workaraound for such situation? The only thought
that I have is to add locale parameter to every url but it is so ugly... 

Best regards,
Elena.
-- 
View this message in context: 
http://www.nabble.com/localization-and-session-expiration-tp22366384p22366384.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: localization and session expiration

2009-03-05 Thread Anton Veretennikov
May be cookie?

On Fri, Mar 6, 2009 at 12:20 PM, ElSe els...@mail.ru wrote:


 Hello!

 I have a question: in my application there are several locales and the user
 can choose locale on the fly. Locale is stored in the session and all is ok
 while the session exists. But! When the session is expired the application
 must say user about this and it does - using default locale. It is
 unpleasant - from the user's point of view the application changes locale
 by
 its own will. Is there any workaraound for such situation? The only thought
 that I have is to add locale parameter to every url but it is so ugly...

 Best regards,
 Elena.
 --
 View this message in context:
 http://www.nabble.com/localization-and-session-expiration-tp22366384p22366384.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org