Alistair
Alistair

Reputation: 1979

wicket (1.5) - Load different JS for development/deployment

I want to have something like the following.

<head>
   <% if deployment == true %>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
   <% else %>
   <script src="js/lib/ref/jquery-1.6.2.js"></script>
   <% endif %>       
</head>

How can I do this in wicket?

Update:

Sorry, I was simplifying. Actually I want to include this just before the close body tag.

Upvotes: 1

Views: 655

Answers (1)

Andrew Fielden
Andrew Fielden

Reputation: 3899

You can make your WebPage class implement the IHeaderContributer interface.

Then your class can override the following method

public void renderHeader(IHeaderResponse response) {
    if (deployment) {
        response.renderJavascriptReference("https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js");
    }
    else {
        response.renderJavascriptReference("js/lib/ref/jquery-1.6.2.js");
    }

Upvotes: 3

Related Questions