Wicket DropDownChoice设置模型值

时间:2012-01-10 12:44:55

标签: drop-down-menu wicket wicket-1.5

我有一个表(Dataview),其中包含数据库中的内容,其中每个行/对象都有一个“编辑”按钮。当我尝试编辑对象时,DropDownChoice值(在表单中)未正确更新(即使它在数据库中是正确的)。在DDC中设置的值是(sorted)列表“placeList”中的第一项,我显然希望从我的对象中获取正确的值(event.getPlace()。getName())。

这是代码(wicket 1.5):

    List<Place> placesList = UtGuidenApplication.getInstance().getUgpService().getAllPlaces();
    Collections.sort(placesList);

    DropDownChoice<Place> selectablePlaceField = new DropDownChoice<Place>("Sted", new PropertyModel<Place>(event, "eventPlace.name"),
            placesList, new ChoiceRenderer<Place>("name"));
    utguidenEventForm.add(selectablePlaceField);

任何人

干杯, Terje Eithun, 挪威

1 个答案:

答案 0 :(得分:5)

我认为你的模型中有错误。您已编写new PropertyModel<Place>(event, "eventPlace.name"),其中包含您的事件名称作为模型,但选项列表包含地点。我认为使用new PropertyModel<Place>(event, "eventPlace")可以解决问题。

相关问题