我需要在选择后立即更新模型或对象 DropDownChoice 项。
贝娄是我正在工作的代码:
add(new ListView[Company]("listCompanies", listData) {
override protected def onBeforeRender() {
//
// ...
super.onBeforeRender()
}
def populateItem(item: ListItem[Company]) = {
var company = item.getModelObject()
//...
val listClients: java.util.List[Client] = clientControler.listClients
item.add(new DropDownChoice("clientSelection", listClients,new ChoiceRenderer[Client]("name")))
在具有公司对象属性的 ListView 中, 选择 DropDownChoice 的名称属性后,模型 公司将使用所选的客户名称进行更新。
我怎样才能实现这个目标?
谢谢
最佳答案
我认为你可以覆盖 onSelectionChanged。但您还需要重写 WantOnSelectionChangedNotifications 以返回 true 才能使其正常工作。像这样的东西。
DropDownChoice<Client> dropDownChoice = new DropDownChoice("clientSelection", listClients) {
@Override
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected void onSelectionChanged(Object newSelection) {
// Do something here when selection is changed
}
};
关于java - Wicket:更新 DropDownChoice 项目选择事件的模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15892657/