我在wicket中创建一个简单的下拉组件,遵循以下示例:http://www.mkyong.com/wicket/wicket-select-example/
现在我收到错误: 最后一个原因:没有为类定义get方法:class no.polaris.AdressaHomePage expression:2011
有人看到了什么问题吗? (它对于selectedYear的getter没有帮助。)
干杯 Terje Eithun
public class AdressaHomePage extends BasePage {
private String selectedYear = "2011";
public AdressaHomePage(final PageParameters parameters) {
add(new FeedbackPanel("feedback"));
Form<?> form = new Form<Void>("form") {
@Override
protected void onSubmit() {
info("Selected year: " + selectedYear);
}
};
add(form);
Select<String> yearSelector = new Select<String>("year-selector", new PropertyModel<String>(this, selectedYear));
yearSelector.add(new SelectOption<String>("year1", new Model<String>("2012")));
yearSelector.add(new SelectOption<String>("year2", new Model<String>("2011")));
yearSelector.add(new SelectOption<String>("year3", new Model<String>("2010")));
yearSelector.add(new SelectOption<String>("year4", new Model<String>("2009")));
form.add(yearSelector);
}
}
答案 0 :(得分:3)
new PropertyModel(this,“selectedYear”)
请注意引号。