Reputation: 435
In my wicket application I have a datatable. A dataprovider is attached to it and loads the content from a REST-Service. This call needs a lot of time (~ 20 seconds).
So, is there a way to load the page with an empty table and then refilling it after being rendered with data from the Service?
I thought about reattaching or reloading the dataprovider after the page is rendered:
onAfterRender()
But I still don't know how to do that with a dataprovider.
Upvotes: 0
Views: 909
Reputation: 3183
You could take a look at the AjaxLazyLoadPanel
which shows a little loading icon as placeholder while the Component is loaded.
add(new AjaxLazyLoadPanel("table") {
@Override
public Component getLazyLoadComponent(String markupId) {
return new MyLongLoadingTable(markupId);
}
});
Another solution: show the empty table and periodically check for the database operation to complete and update the table when all data gathering has been done. The AbstractAjaxTimerBehavior
is a good utility. Like this:
add(new AbstractAjaxTimerBehavior(Duration.ONE_SECOND) {
@Override
protected void onTimer(AjaxRequestTarget target) {
if (isDataLoaded()) {
stop(target);
target.add(table);
}
}
});
Upvotes: 4