gpt4 book ai didi

java - Wicket:更新 DropDownChoice 项目选择事件的模型

转载 作者:行者123 更新时间:2023-12-01 06:31:03 24 4
gpt4 key购买 nike

我需要在选择后立即更新模型或对象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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com