【发布时间】:2014-06-21 13:33:46
【问题描述】:
我想在单击按钮时更改列表视图的数据。
这是我目前所做的:
final PageableListView<Users> listview = new PageableListView<Users>("rows", displayList, 10) {
//....
protected void populateItem(final ListItem<Users> item) {
item.add(new Label("username").setOutputMarkupId(true));
// .. other fields
}
}
final IndicatingAjaxFallbackLink<MyPanel> sublist = new IndicatingAjaxFallbackLink<MyPanel>("sublist") {
public void onClick(AjaxRequestTarget target) {
displayList = // get new list
listview.setList(displayList);
target.addChildren(listview, Label.class);
}
};
add(sublist);
如果新列表的大小与旧列表的大小完全相同,则此方法有效。在任何其他情况下,我都会得到一个
Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
我该如何解决这个问题?
【问题讨论】:
-
我会将整个列表添加到目标中,例如
target.add(listview);。更新部分列表时存在一些已知的 ajax IE 问题。 -
我已经尝试过了,但列表视图无法替换(据我所知):
This component is a repeater and cannot be repainted via ajax directly. Instead add its parent or another markup container higher in the hierarchy.