We are developing a Wicket application with heavy use of AJAX, and we've encountered an issue with panels contributing CSS via the renderHead()
method. The problem arises when panels are replaced using AJAX functions, such as an AjaxTabbedPanel
, as the header contributions from the old panels remain in the application and cause conflicts. This not only leads to response bloat but also causes rendering issues in other parts of the application when CSS declarations are too generic.
Is there a solution to this problem? Perhaps a way to recreate the IHeaderResponse
when a panel is replaced or no longer visible?
Below is an example of how our header contributor is implemented:
@Override
public void renderHead(IHeaderResponse response) {
response.renderCSSReference(new SharedResourceReference(SearchMainPanel.class, "Search.css"));
}
We are using Wicket 1.5.3.
Although I have managed to address this issue by including a custom label that renders a
<link rel="stylesheet" ... />
in the Panel's body markup instead of using header contributors, we faced compatibility problems with IE8 not recognizing the presence of this CSS. Therefore, we need to reconsider our approach.