thoredge
thoredge

Reputation: 12591

Make Apache Wicket load jquery for all pages

I've got some javascript going on on my pages in addition to Wickets use. However, Wicket only loads jquery on pages where it sees that it is needed. Is there any way to make Wicket load jquery on all pages?

I'd hate to include jquery a second time.

Upvotes: 12

Views: 3937

Answers (1)

Christoph Leiter
Christoph Leiter

Reputation: 9345

Yes. You can include it in your base page so that it is available for all pages:

@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);

    response.render(JavaScriptHeaderItem.forReference(getApplication().getJavaScriptLibrarySettings()
        .getJQueryReference()));  
}

Wicket is smart enough to not include the reference multiple times if it is requested elsewhere too.

Upvotes: 19

Related Questions