任何人都可以告诉我,为什么这个来源
List<Data> datas = ~getData();
PropertyListView<Data> listView =
new PropertyListView<Data>("listView", new PropertyModel<List<Data>>(this, "datas")){
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<Data> item) {
Data data = item.getModelObject();
item.add(new MultiLineLabel("textLabel", data.getText());
@SuppressWarnings("unchecked")
ArrayList<DataParam> params = (ArrayList<DataParam>) ~getParamsForData(data);
DropDownChoice<DataParam> dropDownChoice =
new DropDownChoice<DataParam>("choiceSelector", new Model<ArrayList<DataParam>>(params), new ChoiceRenderer<Object>("key", "value")){
private static final long serialVersionUID = 1L;
@Override
protected boolean wantOnSelectionChangedNotifications(){
return true;
}
@Override
protected void onSelectionChanged(DataParam newSelection) {
super.onSelectionChanged(newSelection);
}
};
item.add(dropDownChoice);
}
};
public static final class DataParam implements Serializable{
private String key;
private String value;
public DataParam(String key, String value){ this.key=key; this.value=value;}
public String getKey() { return key; }
public void setKey(String key) { this.key = key; }
public String getValue() { return value; }
public void setValue(String value) { this.value = value; }
}
抛出此异常
WicketMessage: No get method defined for class:
class Data expression: choiceSelector
Root cause:
org.apache.wicket.WicketRuntimeException:
No get method defined for class: class Data expression: choiceSelector
? (所以在Data类中寻找selectSelector wicket组件id的get方法?!)我甚至不理解
答案 0 :(得分:5)
Wicket正在寻找一个模型来读取和存储用户所做的选择(以及最初选择的值)。
由于您使用的是没有模型的DDC构造函数,因此wicket正在查看CompoundPropertyModel的DDC(项目)的父级,并使用DDC的wicket:id作为表达式。因此,你得到'choiceSelectecor'。
你要么必须使用wicket:id来数学Data类的结构,要么用这个模型构建一个DDC。
伯特