Little problem with DropDownChoice. I build a DropDownChoice with a list of Object. Take for example:
public MyClass
private String code;
private String description;
[...]
than take another Object
public FormModelObject
private String code;
I can easly build the DropDownChoice selecting what show (description property) and what obtain (code property) using ChoiceRender.
Unfortunally the DropDownChoice return the entire Object (MyClass) and I cannot set the property Code inside FormModelObject (it simply launch a toString() method on MyClass).
How can I obtain it without using Ajax?
Thanks
Well, you could override method onModelChanged() of DropDownChoice and update residenceZipCode with the new value. Something like :
DropDownChoice<City> drop = new DropDownChoice<City>("residenceZipCode",new Model(), cityList,new ChoiceRenderer<City>("name", "zipcode")){
onModelChanged(){
String newZipCode = (String)PropertyResolver.getValue("zipCode",getModelObject());
PropertyResolver.setValue("residenceZipCode", res, newZipCode, new PropertyResolverConverter());
}
};
DropDownChoice must have its own model.