From: Erik Brakkee Date: Fri, 27 Aug 2010 22:37:30 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.7~69 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=0e68c3016f4a5c40c7d16b9a69c52721f9cc7a43;p=utils --- diff --git a/wicket/components/src/main/java/org/wamblee/wicket/jquery/JQueryBehavior.java b/wicket/components/src/main/java/org/wamblee/wicket/jquery/JQueryBehavior.java index fb142ba6..0efab6fa 100644 --- a/wicket/components/src/main/java/org/wamblee/wicket/jquery/JQueryBehavior.java +++ b/wicket/components/src/main/java/org/wamblee/wicket/jquery/JQueryBehavior.java @@ -18,7 +18,6 @@ package org.wamblee.wicket.jquery; 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. @@ -30,16 +29,28 @@ public class JQueryBehavior extends HeaderContributor { 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() {