模型正在更新,但pageablelistview不能反映UI + wicket上的更改

编程入门 行业动态 更新时间:2024-10-11 03:21:04
本文介绍了模型正在更新,但pageablelistview不能反映UI + wicket上的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,我在提交此按钮时将执行该功能,并且需要从列表中删除选中的复选框.

So I have this button on submitting it there is some functioning which will be performed and the selected checkbox needed to be removed from the list.

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

The piece of code below shows the usage of that button and the implementation I have done to remove the particular checkbox selection.

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));

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

So I found that my models are getting updated but the same is not happening on the UI i.e. I want the selected checkboxes to be removed from the refreshed list..... Please suggest......

推荐答案

来自ListView#setReuseItems():

但是,如果您修改listView模型对象,则必须手动调用listView.removeAll()才能重建ListItems.

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

因此,如果reuseItems为true,则在更改模型时,将在列表视图上调用removeAll.

So if reuseItems is true, then at the point where you change your model call removeAll on the listview.

更多推荐

模型正在更新,但pageablelistview不能反映UI + wicket上的更改

本文发布于:2023-08-06 14:40:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1313030.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模型   pageablelistview   wicket   UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!