I have a DataInputPanel extends FormComponentPanel which shows a
CityDropDownChoice extends DropDownChoice :


public class DataInputPanel extends FormComponentPanel
{
  private CityDropDownChoice cityDropDownChoice;

  public DataInputPanel(String id , IModel model)
  {
    super(id , model);

    cityDropDownChoice = new CityDropDownChoice("city" , new
PropertyModel(model , "city") , Arrays.asList(Cities.values()));
    add(cityDropDownChoice);
  }
}

I found this doesn't work , because no matter the user selects , it always
shows the default city in the model.
That is , model.setCity(...) is always not called.

So I change the code to :

public class DataInputPanel extends FormComponentPanel
{
  private CityDropDownChoice cityDropDownChoice;

  public DataInputPanel(String id , IModel model)
  {
    super(id , model);

    cityDropDownChoice = new CityDropDownChoice("city" , new
PropertyModel(this , "myModel.city") , Arrays.asList(Cities.values()));
    add(houseSystemDropDownChoice);
  }

  public IModel getMyModel()
  {
    return getModel();
  }
}

It works , but it is ugly !
Because the getMyModel() method is in fact , redundant.
It just works for PropertyModel(this , "myModel.city")

Is it a design fault ?
Is there any way to get rid of this method ?

Reply via email to