Thanks again!
It's now much clearer!!
for some reason i have error on CookieUtils... so i implement it like this:
(on my HomePage.java)
form.add(new SubmitLink("English"){
@Override
public void onSubmit() {
getSession().setLocale(new Locale("en_US"));
Cookie languageCookie = new
Cookie(WicketApplication.LANGUAGE_COOKIE_NAME, "en_US");
languageCookie.setMaxAge(WicketApplication.LANGUAGE_COOKIE_AGE);
((WebResponse)getResponse()).addCookie(languageCookie);
}
});
*one last thing:*
so the "Session.get().setLocale(locale)" i should implement in
WicketApplication?
like this:
@Override
public Session newSession(Request request, Response response) {
Session session = super.newSession(request, response);
session = trySetLanguageFromCookie(session, request, response);
return session;
}
private Session trySetLanguageFromCookie(Session session, Request
request,
Response response) {
Cookie[] cookies = ((WebRequest) request).getCookies();
if (cookies == null || cookies.length == 0) {
return session;
}
for (Cookie cookie : cookies) {
if (LANGUAGE_COOKIE_NAME.equals(cookie.getName())) {
session.setLocale(new Locale(cookie.getValue()));
cookie.setMaxAge(LANGUAGE_COOKIE_AGE);
((WebResponse)response).addCookie(cookie);
break;
}
}
return session;
}
10x!
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/set-locale-in-cookie-tp4649827p4649831.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]