this.add(new RequiredTextField("nom", new PropertyModel(this.personne, "nom")).setLabel(new Model("Nom")));
this.add(new RequiredTextField("prenom", new PropertyModel(this.personne, "prenom")).setLabel(new Model("Prenom")));
this.add(new RequiredTextField("adresse", new PropertyModel(this.personne, "adresse")).setLabel(new Model("Adresse")));
this.add(new RequiredTextField("ville", new PropertyModel(this.personne, "ville")).setLabel(new Model("Ville")));
final ProvincesDropDownChoice province = new ProvincesDropDownChoice("province", new PropertyModel(this.personne, "province"));
province.setLabel(new Model("Province"));
this.add(province);
this.add(new PaysDropDownChoice("pays", new PropertyModel(this.personne, "pays")){
private static final long serialVersionUID = -2426618314309535060L;
@Override
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected void onSelectionChanged(final Object newSelection) {
final String pays = (String) newSelection;
if(pays == "Canada"){
province.clearInput();
province.setRequired(true);
province.setCanada();
province.setEnabled(true);
}
else if(pays == "Etats-Unis"){
province.clearInput();
province.setRequired(true);
province.setUSA();
province.setEnabled(true);
}
else{
province.clearInput();
province.setEnabled(false);
province.setRequired(false);
}
}
}