java Wicket如何使用ajax刷新表中的单行
在我的wicket应用程序中,我有一个表,其中一行的每一列都由一个bean描述。其中一列包含一个ajax组件,可以更改bean中的值,从而更改其他列中显示的值
如何在不重新加载整个表的情况下更新这些列
现在我使用以下代码:
public static <T> void refreshTableRow(AjaxRequestTarget target, Item<ICellPopulator<T>> columnItem) {
for (Component component : columnItem.getParent()) {
if (component instanceof Item) {
((Item<?>) component).stream()
.filter(Component::getOutputMarkupId)
.forEach(target::add);
}
}
}
但是为了正确地使用这段代码,我必须为在IColumn#populateItem
中创建的每个列的根组件设置outputMarkupId(true)
还有别的办法吗
# 1 楼答案
重写
DataTable#newRowItem()
并返回一些具有outputMarkupId = true
的自定义项实现然后在Ajax回调方法中执行以下操作: