package org.wicketTutorial.localizechoices;
import java.awt.Color;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import org.apache.wicket.Session;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.wicketTutorial.commons.bootstrap.layout.BootstrapBasePage;
import org.apache.wicket.model.Model;
public class HomePage extends BootstrapBasePage {
private static final long serialVersionUID = 1L;
public HomePage(final PageParameters parameters) {
super(parameters);
List<Locale> locales = Arrays.asList(Locale.ENGLISH, Locale.ITALIAN, Locale.GERMAN);
List<String> colors = Arrays.asList("green", "red", "blue", "yellow");
final DropDownChoice<Locale> changeLocale = new DropDownChoice<Locale>("changeLocale", new Model<Locale>(), locales);
StatelessForm form = new StatelessForm("form"){
@Override
protected void onSubmit() {
Session.get().setLocale(changeLocale.getModelObject());
}
};
DropDownChoice<String> selectColor = new DropDownChoice<String>("selectColor", new Model<String>(), colors){
@Override
protected boolean localizeDisplayValues() {
return true;
}
};
form.add(selectColor);
setStatelessHint(true);
add(form.add(changeLocale));
}
}