Thank you, Martin! That’s an interesting way to fix this.
Didn’t think of that, and it fits quite well with our current code, too. We can put our own “requestedLocale” field in our WebSession subclass, and use that if the session is temporary. Thanks! Met vriendelijke groet, Kind regards, Bas Gooren Op 26 mei 2018 bij 13:41:25, Martin Grigorov (mgrigo...@apache.org) schreef: Hi, Here is another solution: - put the locale in RequestCycle's metadata - override Session#getLocale() and if Session#isTemporary() then use the metadata, otherwise use the session's locale On Fri, May 25, 2018 at 7:20 PM, Bas Gooren <b...@iswd.nl> wrote: > Hi! > > We build mainly e-commerce websites on wicket, which means most pages are > publicly visible and indexable. > Since our websites are multi-language we have a custom > CompoundRequestMapper which checks if the url contains a valid locale, and > updates the session locale accordingly. > > This works great! With one small issue we would ideally like to fix: wicket > binds the session once you call setLocale on it. As a result, every > (stateless) public url that is requested leads to a session being created, > and a cookie being sent to the requester. > > Since every component (effectively) depends on Session.get().getLocale() to > get the current locale, we see no other way to handle this cleanly. > > Writing this now and having another look at the wicket source code, I > reckon we could wrap the wicket request and override its getLocale() > method. I probably hesitated to do so before because wicket expects a > ServletWebRequest in some places, so the wrapper cannot simply extend the > base Request class. > Anyone here that has a good solution for this? Otherwise we have to check > for implementations and decide on the wrapper based on that, but that’s > rather ugly code. > > Also, I realize that we don’t just want to wrap the request for request > mapping purposes (in our compound mapper). We need to wrap the request > earlier, since we need to ensure the actual request passed in to the > session constructor returns a locale that matches with the url. > > Would appreciate any thoughts you have on this. > > Thanks! > > Met vriendelijke groet, > Kind regards, > > Bas Gooren >