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 <[email protected]> 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 <[email protected]>
>> 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: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
> 
> 

-- 
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to