I faced the same problem and was able to solve it with wicket only:
Make a Class derived from GenericPanel
(or just Panel
) which contains:
IModel<Long> currentOffsetModel
ListView
AjaxLink
- empty
div
(or any other placeholder element) asWebmarkupContainer
- LoadalbeDetechable Model to load the List for the ListView starting at currentOffsetModel
In the AjaxLink-onClick
Method you need to replace the placeholder div
with the new Object of your custom class ("replaceWith"), set the AjaxLink visibility to false and
the AjaxLink and the new Object to 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();
}
};
...
}
Corresponding html:
<wicket:panel> <wicket:container wicket:id="listItem"/> <a wicket:id="next">Next</a> <div wicket:id="placeholder"></div> </wicket:panel>