gpt4 book ai didi

java - 模型正在更新,但 pageablelistview 未反射(reflect) UI + wicket 上的更改

转载 作者:行者123 更新时间:2023-12-01 15:15:25 32 4
gpt4 key购买 nike

因此,我有一个提交按钮,其中将执行一些功能,并且需要从列表中删除选定的复选框。

下面的代码显示了该按钮的用法以及我为删除特定复选框选择所做的实现。

       Button resumeDrive = new AjaxButton("resume", driveSearchForm)
/**
*
*/
private static final long serialVersionUID = -7016746377299867219L;

@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
log.info("envoking resume");
target.addComponent(form);
try {

List<DashboardModel> list = (List<DashboardModel>) group.getDefaultModelObject();
log.info("drives data : " + list);
if (list != null) {
List<Long> drives = new ArrayList<Long>();
List<DashboardModel> drivesToRemove = new ArrayList<DashboardModel>();
for (DashboardModel drive : list) {
drives.add(drive.getExecutionUnitId());

drivesToRemove.add(drive);
log.info("drivesToRemove :" + drivesToRemove);
}
log.info("selected drive: " + drives);
if (drives.size() > 0) {
log.info("Execution Ids to resume : " + drives);

driveResumeService.resumeDrives(drives);
drivesData.removeAll(drivesToRemove);
log.info("drivesdata :" + drivesData);

warn("Execution Ids to resume : " + drives);
} else {
warn("No drives selected for resuming.");
}
} else {
info("No drives to resume.");
}
} catch (Exception e) {
warn("Failed to resume jobs. " + e.getMessage());
log.info("Failed to resume jobs", e);
}
target.addComponent(group);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.addComponent(form);
}
driveSearchForm.add(resumeDrive);
resumeDrive.setDefaultFormProcessing(true);
resumeDrive.add(new AjaxFormValidatingBehavior(driveSearchForm, "onClick"));

--> my model returns this driveData.
---> I'm sticking the pageableListView code also alongside.

private CheckGroup<DashboardModel> group;
group = new CheckGroup<DashboardModel>("group", new ArrayList<DashboardModel>());
driveSearchForm.add(group);
group.add(new CheckGroupSelector("allSelected"));
group.setOutputMarkupId(true);

pageableListView = new PageableListView<DashboardModel>("searchResults", driveDataModel, 10) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<DashboardModel> item) {
item.add(new Check("check", item.getModel()));
item.add(new Label("name", item.getModelObject().getName()));
item.add(new Label("status", item.getModelObject().getStatus().toString()));
item.add(new Label("driveUrl", item.getModelObject().getDriveURL()));
}

};
pageableListView.setRenderBodyOnly(false);
pageableListView.setReuseItems(true);
group.add(pageableListView);
group.add(new PagingNavigator("navigator", pageableListView));

所以我发现我的模型正在更新,但用户界面上却没有发生同样的情况,即我希望从刷新的列表中删除选定的复选框......请建议......

最佳答案

来自ListView#setReuseItems():

But if you modify the listView model object, than you must manually call listView.removeAll() in order to rebuild the ListItems.

因此,如果 reuseItems 为 true,则在更改模型时会在 ListView 上调用 removeAll

关于java - 模型正在更新,但 pageablelistview 未反射(reflect) UI + wicket 上的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11668683/

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