Wicket DropDownChoice设置模型值

Ter*_*hun 0 wicket wicket-1.5 drop-down-menu

我有一个表(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);
Run Code Online (Sandbox Code Playgroud)

任何人?

干杯,Terje Eithun,挪威

r3n*_*nj1 5

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