My current project allows the user to change the language all pages are displayed in on each page (by clicking on one of a row of flag icons). Here is the implementation of the link:
Link<Locale> changeLocaleLink = new Link<Locale>("link", locale) {
@Override
public void onClick() {
Locale newLocale = getModelObject();
// nothing esoteric done with setLocale(...) in MySession
MySession session = MySession.get();
session.setLocale(newLocale);
if (session.isSignedIn()) {
// set the new locale in the user's preferences
}
setResponsePage(getPage());
}
};
With Wicket 1.5, this worked without problems. The page reloaded and all labels were changed accordingly. However, since I’ve migrated my code to Wicket 6.0, only some (seemingly random) labels are changing upon changing the locale, so I’ve no idea what causes the issue.
I’m using (Wicket-)standard ResourceModels and resource files for all of my labels.
Please note that using:
setResponsePage(getPage().getClass());
and
setResponsePage(getPage().getClass(), getPage().getPageParameters());
doesn’t work for me, since the code should work for all pages and I have quite a few stateful, non-bookmarkable pages whose constructors don’t follow the above patterns.
Has anybody experienced the same with Wicket 6.0?
EDIT: It seems that most, but not all labels of Links are affected! Also, I don’t see any exceptions thrown when this happens.
EDIT2: Due to svenmeier’s request, I’ve done more research. All links which aren’t updated accordingly are constructed as follows:
BookmarkablePageLink<MyPage> link
= new BookmarkablePageLink<MyPage>(ID, MyPage.class, params);
link.setBody(new ResourceModel("My.Internationalized.Text"));
So it seems that the model which is set as body model isn’t updated by the link component. Which leaves the question why that did work with Wicket 1.5.
The issue has been fixed in Wicket 6.1.0! Unfortunately I can’t say which fix did the job, though WICKET-4738 sounds a lot like my issue.