Reputation: 3058
I am having some issues with a Wicket ListPanel. The whole ListPanel is refreshed via Ajax from a filter that is defined on the same page. This schema works quite well under normal circumstances.
One part of the ListPanel is a component that needs some specific JS and CSS files for it's proper functioning. These are declared in the wicket:head section of the specific component.
When the page is loaded for the first time and the list has at least one item, everything works fine. However, when the list is empty when page is rendered, the child component of the ListPanel is never loaded and the CSS/JS imports are not considered. If, afterwards you refresh the DIV with an AJAX request, the wicket:head section of that component is not reloaded, so the Javascript code is broken.
My assumption is that Wicket will consider the wicket:head section during normal page render, but not when a component is updated via AJAX.
So, my question is, what would be a good approach to get the resources I need without having to push the imports up to a component that doesn't use the resources directly? I know pushing them up to other components or the page will do the job, but I don't really think it's clean, I like to have things where they belong, and if a component is the only one to use some resources, they should only be loaded there.
Upvotes: 3
Views: 738
Reputation: 3583
In your listPanel
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.renderOnDomReadyJavaScript("someDomReadyJSFunction();");
}
your JS should have a function to be called on domready, that will do the work in wicket 1.5.x for wicket 6 check this
Upvotes: 0