我使用 wicket,并且创建了一个像这样的列表选择并覆盖了 onSelectionChanged:
ListChoice<String> hotelList = new ListChoice<String>("hotel",
new PropertyModel<String>(this, "selectedHotel"), hotelLabels) {
@Override
protected void onSelectionChanged(String newSelection)
{
super.onSelectionChanged(newSelection);
System.out.print("Tesy");
}
};
但它不起作用 - 程序永远不会触发此方法。我不想使用 onSubmit 来处理这个问题。当有人单击列表中的某项时,我需要采取行动。
如何在 Wicket 口执行此操作?
最佳答案
final ListChoice<String> hotelList = new ListChoice<String>("hotel", new PropertyModel<String>(this, "selectedHotel"), hotelLabels);
hotelList.add(new AjaxFormComponentUpdatingBehavior("onchange") {
protected void onUpdate(AjaxRequestTarget target) {
System.out.print(hotelList.getModel().getObject());
}
});
hotelList.setOutputMarkupId(true);
关于java - onSelectionChanged 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22345992/