PropertyModel is aware of the IModel you are passing and unwraps it.
So depending on what is inside your model you have different options:
-the model contains an object x which has a city property:
make sure x has a getter and setter for city this will be used by the
propertymodel
-the model contains a city object:
do not use a propertymodel at all or use "" as the expression.
Maurice
On Sat, May 10, 2008 at 11:50 PM, smallufo <[EMAIL PROTECTED]> wrote:
> 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 ?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]