well here are some code snippets:
Links without classes - everything is OK
private void addLocaleSwitchers() {
// add english link
enLink = new LocaleSwitchLink ("english", Locale.ENGLISH);
add (enLink);
// add czech link
czLink = new LocaleSwitchLink ("czech", new Locale ("cs"));
add (czLink);
}
private final class LocaleSwitchLink extends Link {
private Locale toSwitch;
public LocaleSwitchLink (String s, Locale toSwitch) {
super (s);
this.toSwitch = toSwitch;
}
@Override
public void onClick() {
getSession().setLocale (toSwitch);
}
}
------------------------------------------------------------------------------------------------------------------
Links with classes - I do not know how to refresh locales in AjaxLink
private void addLocaleSwitchers() {
Locale currentLocale = this.getSession().getLocale();
// add english link
enLink = new LocaleSwitchLink ("english", Locale.ENGLISH);
if (currentLocale.equals(Locale.ENGLISH)) {
enLink.add (new AttributeModifier ("class", true, new Model
("activeLanguage")));
}
//enLink.setOutputMarkupId(true);
add (enLink);
// add czech link
czLink = new LocaleSwitchLink ("czech", new Locale ("cs"));
if (currentLocale.equals(new Locale("cs"))) {
czLink.add (new AttributeModifier ("class", true, new Model
("activeLanguage")));
}
//czLink.setOutputMarkupId(true);
add (czLink);
}
private final class LocaleSwitchLink extends AjaxLink {
private Locale toSwitch;
public LocaleSwitchLink (String s, Locale toSwitch) {
super (s);
this.toSwitch = toSwitch;
}
@Override
public void onClick (AjaxRequestTarget target) {
target.addComponent (enLink);
target.addComponent (czLink);
getSession().setLocale (toSwitch);
}
}
I think that the problem is that I do not know how to set locale via
ajaxRequestTarget.
Again thanks for any advices
Milan
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]