【发布时间】:2014-01-03 13:08:06
【问题描述】:
我正在尝试将 Wicket PagingNavigator 添加到我的 Wicket WebPage 的页脚面板中,但与之相关的 PageableListView 位于页面正文中。
我已经建立了一个 Wicket 基本页面,它有一个简单的页脚面板。然后,我创建了一个 WebPage,它扩展了我的基本页面,因此继承了我的页脚面板。
在我的网页上,我添加了一个运行良好的 PageableListView。我的问题是我现在希望为我的 PageableListView 添加一个 PagingNavigator,但我想将 Navigator 添加到我的页脚面板中。
当我调用我的 WebPage 的构造函数时,它的第一个调用是 super(),这反过来会将我的页脚添加到页面中,然后我的 PageableListView 在页脚构造函数已经被调用之后添加。
我尝试通过在页脚中添加一个带有空模型的虚拟 PageableListView 来解决此问题,然后在将 PageableListView 填充到 WebPage 后立即将其更新为我的实际 ListView。但是,看起来我在页脚面板中的 PagingNavigator 仍在静态引用初始虚拟 ListView。有什么想法可以让我的 PagingNavigator 在页脚中引用正确的 PageableListView 吗?
提前感谢任何可以为我指明正确方向的人,让我能够正确地将我的 PagingNavigator 添加到我的页脚面板...
基本页面:
public class BasePage extends WebPage {
private Component footerPanel;
public BasePage() {
add(footerPanel = new FooterPanel("FooterPanel"));
}
public Component getFooterPanel() {
return footerPanel;
}
}
页脚面板:
public class FooterPanel extends Panel {
private PageableListView listView = new PageableListView("dummy", new Model(), 1) {
@Override
protected void populateItem(ListItem listItem) {
}
};
public FooterPanel(String id) {
super(id);
add(new PagingNavigator("navigator", listView));
}
public void setListView(PageableListView listView) {
this.listView = listView;
}
}
我的页面:
public class MyPage extends BasePage {
public MyPage() {
super();
MyModel model = new MyModel();
PageableListView listView = new PageableListView<IModel>("list", model, 5) {
@Override
protected void populateItem(ListItem item) {
final DomainObject object = (DomainObject) item.getModelObject();
item.add(new Label("label", object.getSomething()));
}
};
add(listView);
FooterPanel footer = (FooterPanel)this.getFooterPanel();
footer.setShiftList(shiftList);
}
}
【问题讨论】: