import org.apache.wicket.Application;
import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.JavascriptPackageResource;
-import org.apache.wicket.markup.html.resources.JavascriptResourceReference;
/**
* JQuery bahavior which adds the jquery javascript.
static final String JQUERY_DEPLOYMENT = "jquery-1.4.2.min.js";
static final String JQUERY_DEVELOPMENT = "jquery-1.4.2.js";
+ private static HeaderContributor CACHE;
+
/**
* Constructs the behavior.
*/
public JQueryBehavior() {
- super(initializeInstance());
+ super(getContributor());
}
- private static HeaderContributor initializeInstance() {
- return JavascriptPackageResource.getHeaderContribution(
- JQueryBehavior.class, getJQueryJavascript());
+ /**
+ * Resets the cached value of the header contribution. Used typically for test only.
+ */
+ public static void clear() {
+ CACHE = null;
+ }
+
+ private static HeaderContributor getContributor() {
+ if (CACHE == null) {
+ CACHE = JavascriptPackageResource.getHeaderContribution(
+ JQueryBehavior.class, getJQueryJavascript());
+ }
+ return CACHE;
}
private static String getJQueryJavascript() {