Hi again,
Just to add to this that the following will work for pages with parameters:
@Override
protected void onSelectionChanged(Locale newSelection) {
super.onSelectionChanged(newSelection);
// the following tells wicket to instantiate a new page using
the current page's class
getRequestCycle().setResponsePage(getPage().getClass(),
getPage.getParameters());
}
On 23/8/2011 10:41 μμ, Alexandros Karypidis wrote:
Hi Gregor,
I've found a way to do this by manipulating the request cycle.
However, it will only work if you don't mind losing any page state, as
it generates a new page rendering. I do this by overriding
onSelectionChanged(...) of the DropDownChoice<Locale> as follows:
@Override
protected void onSelectionChanged(Locale newSelection) {
super.onSelectionChanged(newSelection);
// the following tells wicket to instantiate a new page using
the current page's class
getRequestCycle().setResponsePage(getPage().getClass());
}
Maybe a more knowledgeable user could suggest a better alternative?
On 23/8/2011 9:13 μμ, Gregor Kaczor wrote:
I have exactly the same problem, though i use an xml file for the
translations. Any help out there?
On 08/23/2011 02:09 PM, Alexandros Karypidis wrote:
Hello,
I have written a locale selector by extending DropDownChoice (you
can see the essential stuff of the implementation below). The
problem is that when the user changes the locale, the page needs to
be re-rendered using the newly selected locale. This does NOT
happen. Instead, only the "<select>" input box seems to be refreshed
to use the new locale, whereas the rest of the page content is still
rendered using the previously selected locale. However, the locale
has been changed in the Session which can be seen when the user
navigates to another page (e.g. by clicking on a link), as the new
page is rendered using the newly-selected locale.
So, how can I force the current page to be re-rendered?
Implementation of my locale selector is as follows:
Markup: <select wicket:id="localeSelection"></select>
Component code:
public class LocaleDropDown extends DropDownChoice<Locale> {
//...
public LocaleDropDown(final String id, final List<Locale>
choices) {
// ...
setModel(new IModel<Locale>() {
public Locale getObject() {
return getSession().getLocale();
}
@Override
public void setObject(Locale locale) {
getSession().setLocale(locale);
// need something here to tell wicket to refresh the
entire page?
}
});
// ...
}
@Override
protected boolean wantOnSelectionChangedNotifications() {
// post an event when user changes the selected value in the
drop-down box
return true;
}
}
-- Kind regards, Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]