On Fri, 18. Sep 2009, Stephan Windmüller wrote:
> > Use a RequestFilter for setting the locale.
> But I am unsure about how to implement this.
Okay, I asked for help a little too quickly. Some things I figured out
myself, but still the filter does not work.
> Additionally I have to figure out if the user is logged in because
> otherwise the database will return an error when I receive the saved
> locale. The Request class does not have getRemoteUser().
Here I used RequestGlobals.
> And is it possible to use Beans in the RequestFilter which I would
> Inject on normal pages?
That is possible using the build-Methods in AppModule itself.
So my code looks now like this:
public RequestFilter buildLocaleFilter(final RequestGlobals globals, final
PersistentLocale persistentLocale){
return new RequestFilter(){
public boolean service(Request request, Response response, RequestHandler
handler) throws IOException {
if (globals.getHTTPServletRequest().getRemoteUser() != null) {
Locale preferredLanguage = getDatabaseUser().getPreferredLanguage();
persistentLocale.set(preferredLanguage);
}
return handler.service(request, response);
}
};
}
According to the debug output the locale is set, but that did not change
anything on the page.
- Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]