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

Reply via email to