我遇到了同样的问题,并且只能用 wicket 解决它:制作一个派生自GenericPanel
(或只是Panel
)的类,其中包含:
IModel<Long> currentOffsetModel
ListView
AjaxLink
- 空
div
(或任何其他占位符元素)为WebmarkupContainer
- LoadalbeDetechable 模型以从 currentOffsetModel 开始加载 ListView 的列表
在 AjaxLink-onClick
方法中,您需要将占位符 div 替换为自定义类的新对象(“replaceWith”),将 AjaxLink 可见性设置为 false,将 AjaxLink 和新对象设置为 AjaxRequestTarget:
class EndlessListPanel extends Panel {
WebmarkupContainer placeholder = new WebmarkupContainer("placeholder");
...
AjaxLink<Void> nextListElem = new AjaxLink<Void>("next") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
int offset = offsetModel.getObject().intValue();
EndlessListPanel next = new NewsPanelList("placeholder",offset + 5);
placeholder.replaceWith(next);
setVisibilityAllowed(false);
target.add(this, next );
}
@Override
protected void onConfigure() {
// The "if" prevents "previous" EndlessListPanel to query the LDM.
if (isVisibilityAllowed()) {
setVisibilityAllowed(!listing.getObject().isReachedEnd());
}
super.onConfigure();
}
};
...
}
对应的html:
<检票口:面板>
<wicket:container wicket:id="listItem"/>
<a wicket:id="next">下一个</a>
<div wicket:id="placeholder"></div>
</wicket:面板>