You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2009/12/13 10:33:57 UTC

svn commit: r890032 - in /wicket/trunk: wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/ wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/ wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/ma...

Author: jdonnerstag
Date: Sun Dec 13 09:33:55 2009
New Revision: 890032

URL: http://svn.apache.org/viewvc?rev=890032&view=rev
Log:
first attempt on improving HeaderContributors
Issue: WICKET-2265

Added:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssLocationHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssReferenceHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptLocationHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptReferenceHeaderContributor.java
Removed:
    wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/CSSPackageResource.java
Modified:
    wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java
    wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java
    wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxIndicatorAppender.java
    wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/DefaultCssAutoCompleteTextField.java
    wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java
    wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
    wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/JavascriptPackageResource.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/WebPage.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_13.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_15.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/header/MyPage2.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java

Modified: wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java (original)
+++ wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java Sun Dec 13 09:33:55 2009
@@ -23,7 +23,9 @@
 import java.util.Properties;
 import java.util.Map.Entry;
 
+import org.apache.wicket.behavior.CssHeaderContributor;
 import org.apache.wicket.behavior.HeaderContributor;
+import org.apache.wicket.behavior.JavascriptHeaderContributor;
 import org.apache.wicket.behavior.StringHeaderContributor;
 import org.apache.wicket.extensions.yui.YuiLib;
 import org.apache.wicket.markup.html.WebComponent;

Modified: wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java (original)
+++ wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java Sun Dec 13 09:33:55 2009
@@ -213,7 +213,6 @@
 	/**
 	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 	 */
-	@Override
 	public void renderHead(IHeaderResponse response)
 	{
 		if (includeYUILibraries())

Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java (original)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/RatingsPage.java Sun Dec 13 09:33:55 2009
@@ -37,13 +37,13 @@
 	 * Star image for no selected star
 	 */
 	public static final ResourceReference WICKETSTAR0 = new ResourceReference(RatingsPage.class,
-			"WicketStar0.png");
+		"WicketStar0.png");
 
 	/**
 	 * Star image for selected star
 	 */
 	public static final ResourceReference WICKETSTAR1 = new ResourceReference(RatingsPage.class,
-			"WicketStar1.png");
+		"WicketStar1.png");
 
 	/** For serialization. */
 	private static final long serialVersionUID = 1L;
@@ -168,24 +168,25 @@
 	 */
 	public RatingsPage()
 	{
-		add(new RatingPanel("rating1", new PropertyModel<Integer>(rating1, "rating"), 5, new PropertyModel<Integer>(
-				rating1, "nrOfVotes"), true)
+		add(new RatingPanel("rating1", new PropertyModel<Integer>(rating1, "rating"), 5,
+			new PropertyModel<Integer>(rating1, "nrOfVotes"), true)
 		{
 			@Override
-			protected boolean onIsStarActive(int star)
+			public boolean onIsStarActive(int star)
 			{
 				return RatingsPage.rating1.isActive(star);
 			}
 
 			@Override
-			protected void onRated(int rating, AjaxRequestTarget target)
+			public void onRated(int rating, AjaxRequestTarget target)
 			{
 				RatingsPage.rating1.addRating(rating);
 			}
 		});
+
 		add(new RatingPanel("rating2", new PropertyModel<Integer>(rating2, "rating"),
-							new Model<Integer>(5), new PropertyModel<Integer>(rating2, "nrOfVotes"),
-							new PropertyModel<Boolean>(this, "hasVoted"), true)
+			new Model<Integer>(5), new PropertyModel<Integer>(rating2, "nrOfVotes"),
+			new PropertyModel<Boolean>(this, "hasVoted"), true)
 		{
 			@Override
 			protected String getActiveStarUrl(int iteration)
@@ -200,13 +201,13 @@
 			}
 
 			@Override
-			protected boolean onIsStarActive(int star)
+			public boolean onIsStarActive(int star)
 			{
 				return RatingsPage.rating2.isActive(star);
 			}
 
 			@Override
-			protected void onRated(int rating, AjaxRequestTarget target)
+			public void onRated(int rating, AjaxRequestTarget target)
 			{
 				// make sure the user can't vote again
 				hasVoted = Boolean.TRUE;

Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxIndicatorAppender.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxIndicatorAppender.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxIndicatorAppender.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxIndicatorAppender.java Sun Dec 13 09:33:55 2009
@@ -22,7 +22,7 @@
 import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.IAjaxIndicatorAware;
-import org.apache.wicket.behavior.AbstractBehavior;
+import org.apache.wicket.behavior.AbstractHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
 
 /**
@@ -38,9 +38,8 @@
  * @since 1.2
  * 
  * @author Igor Vaynberg (ivaynberg)
- * 
  */
-public class AjaxIndicatorAppender extends AbstractBehavior
+public class AjaxIndicatorAppender extends AbstractHeaderContributor
 {
 	/**
 	 * Component instance this behavior is bound to
@@ -57,17 +56,14 @@
 	 */
 	public AjaxIndicatorAppender()
 	{
-
 	}
 
 	/**
-	 * @see AbstractBehavior#renderHead(IHeaderResponse)
+	 * @see AbstractHeaderContributor#renderHead(IHeaderResponse)
 	 */
 	@Override
 	public void renderHead(IHeaderResponse response)
 	{
-		super.renderHead(response);
-
 		if (AjaxRequestTarget.get() != null)
 		{
 			final String javascript = "var e = Wicket.$('" + getMarkupId() +
@@ -131,5 +127,4 @@
 	{
 		this.component = component;
 	}
-
 }

Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/DefaultCssAutoCompleteTextField.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/DefaultCssAutoCompleteTextField.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/DefaultCssAutoCompleteTextField.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/DefaultCssAutoCompleteTextField.java Sun Dec 13 09:33:55 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.extensions.ajax.markup.html.autocomplete;
 
+import org.apache.wicket.behavior.CssHeaderContributor;
 import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.model.IModel;
 

Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java Sun Dec 13 09:33:55 2009
@@ -21,8 +21,9 @@
 import org.apache.wicket.IInitializer;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.ResourceReference;
-import org.apache.wicket.markup.html.CSSPackageResource;
-import org.apache.wicket.markup.html.JavascriptPackageResource;
+import org.apache.wicket.behavior.CssReferenceHeaderContributor;
+import org.apache.wicket.behavior.HeaderContributor;
+import org.apache.wicket.behavior.JavascriptReferenceHeaderContributor;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.upload.FileUploadField;
@@ -114,11 +115,11 @@
 		}
 		setRenderBodyOnly(true);
 
-		add(JavascriptPackageResource.getHeaderContribution(JS));
+		add(HeaderContributor.forJavaScript(JS));
 		ResourceReference css = getCss();
 		if (css != null)
 		{
-			add(CSSPackageResource.getHeaderContribution(css));
+			add(HeaderContributor.forCss(css));
 		}
 
 		final WebMarkupContainer barDiv = new WebMarkupContainer("bar");

Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java Sun Dec 13 09:33:55 2009
@@ -26,9 +26,10 @@
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.IAjaxCallDecorator;
 import org.apache.wicket.ajax.calldecorator.CancelEventIfNoAjaxDecorator;
+import org.apache.wicket.behavior.CssReferenceHeaderContributor;
+import org.apache.wicket.behavior.HeaderContributor;
+import org.apache.wicket.behavior.JavascriptReferenceHeaderContributor;
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.CSSPackageResource;
-import org.apache.wicket.markup.html.JavascriptPackageResource;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.markup.html.resources.CompressedResourceReference;
@@ -248,8 +249,8 @@
 		add(new CloseButtonBehavior());
 		add(new WindowClosedBehavior());
 
-		add(JavascriptPackageResource.getHeaderContribution(JAVASCRIPT));
-		add(CSSPackageResource.getHeaderContribution(CSS));
+		add(HeaderContributor.forJavaScript(JAVASCRIPT));
+		add(HeaderContributor.forCss(CSS));
 	}
 
 	/**

Modified: wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java (original)
+++ wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java Sun Dec 13 09:33:55 2009
@@ -84,10 +84,9 @@
 	}
 
 	/**
-	 * @see org.apache.wicket.behavior.AbstractBehavior#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 	 */
-	@Override
-	public void renderHead(IHeaderResponse response)
+	public void renderHead(final IHeaderResponse response)
 	{
 		CharSequence s = evaluate();
 		if (null != s)

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Sun Dec 13 09:33:55 2009
@@ -39,6 +39,7 @@
 import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.markup.WicketTag;
 import org.apache.wicket.markup.html.IHeaderContributor;
+import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
 import org.apache.wicket.model.IComponentAssignedModel;
 import org.apache.wicket.model.IComponentInheritedModel;
@@ -2491,18 +2492,28 @@
 	{
 		if (isVisibleInHierarchy() && isRenderAllowed())
 		{
+			IHeaderResponse response = container.getHeaderResponse();
+
 			if (this instanceof IHeaderContributor)
 			{
-				((IHeaderContributor)this).renderHead(container.getHeaderResponse());
+				if (response.wasRendered(this) == false)
+				{
+					((IHeaderContributor)this).renderHead(container.getHeaderResponse());
+					response.markRendered(this);
+				}
 			}
 
 			// Ask all behaviors if they have something to contribute to the
 			// header or body onLoad tag.
 			for (IBehavior behavior : getBehaviors())
 			{
-				if (behavior instanceof IHeaderContributor && isBehaviorAccepted(behavior))
+				if ((behavior instanceof IHeaderContributor) && isBehaviorAccepted(behavior))
 				{
-					((IHeaderContributor)behavior).renderHead(container.getHeaderResponse());
+					if (response.wasRendered(behavior) == false)
+					{
+						((IHeaderContributor)behavior).renderHead(container.getHeaderResponse());
+						response.markRendered(behavior);
+					}
 				}
 			}
 		}

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java Sun Dec 13 09:33:55 2009
@@ -69,8 +69,6 @@
 	@Override
 	public void renderHead(IHeaderResponse response)
 	{
-		super.renderHead(response);
-
 		final IDebugSettings debugSettings = Application.get().getDebugSettings();
 
 		response.renderJavascriptReference(WicketEventReference.INSTANCE);

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java Sun Dec 13 09:33:55 2009
@@ -20,8 +20,6 @@
 import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.Response;
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.IHeaderContributor;
-import org.apache.wicket.markup.html.IHeaderResponse;
 
 /**
  * Abstract class for handling Ajax roundtrips. This class serves as a base for javascript specific
@@ -31,14 +29,10 @@
  * @author Ralf Ebert
  * @author Igor Vaynberg
  */
-public abstract class AbstractAjaxBehavior extends AbstractBehavior
+public abstract class AbstractAjaxBehavior extends AbstractHeaderContributor
 	implements
-		IBehaviorListener,
-		IHeaderContributor
+		IBehaviorListener
 {
-	/**
-	 * 
-	 */
 	private static final long serialVersionUID = 1L;
 
 	/** the component that this handler is bound to. */
@@ -84,7 +78,8 @@
 	 * @return the url that references this handler
 	 * @see #getCallbackUrl(boolean)
 	 */
-	@Deprecated // TODO 1.6 Remove
+	@Deprecated
+	// TODO 1.6 Remove
 	public CharSequence getCallbackUrl()
 	{
 		return getCallbackUrl(true);
@@ -141,14 +136,6 @@
 	}
 
 	/**
-	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(IHeaderResponse)
-	 */
-	@Override
-	public void renderHead(final IHeaderResponse response)
-	{
-	}
-
-	/**
 	 * Gets the component that this handler is bound to.
 	 * 
 	 * @return the component that this handler is bound to

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java Sun Dec 13 09:33:55 2009
@@ -18,8 +18,6 @@
 
 import org.apache.wicket.Component;
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.IHeaderContributor;
-import org.apache.wicket.markup.html.IHeaderResponse;
 
 /**
  * Adapter implementation of {@link org.apache.wicket.behavior.IBehavior}. It is recommended to
@@ -29,7 +27,7 @@
  * @author Ralf Ebert
  * @author Eelco Hillenius
  */
-public abstract class AbstractBehavior implements IBehavior, IHeaderContributor
+public abstract class AbstractBehavior implements IBehavior
 {
 	/** */
 	private static final long serialVersionUID = 1L;
@@ -143,13 +141,6 @@
 	}
 
 	/**
-	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
-	 */
-	public void renderHead(IHeaderResponse response)
-	{
-	}
-
-	/**
 	 * @see org.apache.wicket.behavior.IBehavior#isEnabled(Component)
 	 */
 	public boolean isEnabled(Component component)

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractHeaderContributor.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractHeaderContributor.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/AbstractHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.behavior;
 
+import org.apache.wicket.RequestCycle;
 import org.apache.wicket.markup.html.IHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
 
@@ -29,9 +30,6 @@
 	implements
 		IHeaderContributor
 {
-	/**
-	 * 
-	 */
 	private static final long serialVersionUID = 1L;
 
 	/**
@@ -42,33 +40,27 @@
 	}
 
 	/**
-	 * Gets the header contributors for this behavior.
-	 * 
-	 * @return the header contributors; may return null if there are none
+	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 	 */
-	public abstract IHeaderContributor[] getHeaderContributors();
+	public abstract void renderHead(final IHeaderResponse response);
 
 	/**
-	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 * 
+	 * @param location
+	 * @return relative path
 	 */
-	@Override
-	public final void renderHead(final IHeaderResponse response)
+	protected final String returnRelativePath(final String location)
 	{
-		IHeaderContributor[] contributors = getHeaderContributors();
-		// do nothing if we don't need to
-		if (contributors == null)
+		// WICKET-59 allow external URLs, WICKET-612 allow absolute URLs.
+		if (location.startsWith("http://") || location.startsWith("https://") ||
+			location.startsWith("/"))
 		{
-			return;
+			return location;
 		}
 
-		for (int i = 0; i < contributors.length; i++)
-		{
-			if (response.wasRendered(contributors[i]) == false)
-			{
-				contributors[i].renderHead(response);
-				response.markRendered(contributors[i]);
-			}
-		}
+		return RequestCycle.get()
+			.getProcessor()
+			.getRequestCodingStrategy()
+			.rewriteStaticRelativeUrl(location);
 	}
-
 }

Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssHeaderContributor.java?rev=890032&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssHeaderContributor.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.markup.html.resources.CompressedResourceReference;
+
+/**
+ * @author Juergen Donnerstag
+ */
+public class CssHeaderContributor extends AbstractHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	private final Class<?> scope;
+	private final String path;
+	private final String media;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param scope
+	 *            The scope of the package resource (typically the class of the caller, or a class
+	 *            that lives in the package where the resource lives).
+	 * @param path
+	 *            The path
+	 */
+	public CssHeaderContributor(final Class<?> scope, final String path)
+	{
+		this(scope, path, null);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param scope
+	 *            The scope of the package resource (typically the class of the caller, or a class
+	 *            that lives in the package where the resource lives).
+	 * @param path
+	 *            The path
+	 * @param media
+	 *            The media type for this CSS ("print", "screen", etc.)
+	 */
+	public CssHeaderContributor(final Class<?> scope, final String path, final String media)
+	{
+		this.scope = scope;
+		this.path = path;
+		this.media = media;
+	}
+
+	/**
+	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 */
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		if (media == null)
+		{
+			response.renderCSSReference(new CompressedResourceReference(scope, path));
+		}
+		else
+		{
+			response.renderCSSReference(new CompressedResourceReference(scope, path), media);
+		}
+	}
+}

Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssLocationHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssLocationHeaderContributor.java?rev=890032&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssLocationHeaderContributor.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssLocationHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+
+/**
+ * Returns a new instance of a header contributor referencing a CSS file using one of the following
+ * schemes:
+ * <ul>
+ * <li>Starts with http:// or https:// for an external reference.</li>
+ * <li>Starts with "/" for an absolute reference that Wicket will not rewrite.</li>
+ * <li>Starts with anything else, which Wicket will automatically prepend to make relative to the
+ * context root of your web-app.</li>
+ * </ul>
+ * 
+ * @author Juergen Donnerstag
+ */
+public class CssLocationHeaderContributor extends AbstractHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	private final String location;
+	private final String media;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param location
+	 *            The location of the css file.
+	 */
+	public CssLocationHeaderContributor(final String location)
+	{
+		this(location, null);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param location
+	 *            The location of the css file.
+	 * @param media
+	 *            The media type for this CSS ("print", "screen", etc.)
+	 */
+	public CssLocationHeaderContributor(final String location, final String media)
+	{
+		this.location = location;
+		this.media = media;
+	}
+
+	/**
+	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 */
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		if (media == null)
+		{
+			response.renderCSSReference(returnRelativePath(location));
+		}
+		else
+		{
+			response.renderCSSReference(returnRelativePath(location), media);
+		}
+	}
+}

Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssReferenceHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssReferenceHeaderContributor.java?rev=890032&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssReferenceHeaderContributor.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/CssReferenceHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.ResourceReference;
+import org.apache.wicket.markup.html.IHeaderResponse;
+
+/**
+ * @author Juergen Donnerstag
+ */
+public class CssReferenceHeaderContributor extends AbstractHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	private final ResourceReference reference;
+	private final String media;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param reference
+	 */
+	public CssReferenceHeaderContributor(final ResourceReference reference)
+	{
+		this(reference, null);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param reference
+	 * @param media
+	 *            The media type for this CSS ("print", "screen", etc.)
+	 */
+	public CssReferenceHeaderContributor(final ResourceReference reference, final String media)
+	{
+		this.reference = reference;
+		this.media = media;
+	}
+
+	/**
+	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 */
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		if (media == null)
+		{
+			response.renderCSSReference(reference);
+		}
+		else
+		{
+			response.renderCSSReference(reference, media);
+		}
+	}
+}

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -17,25 +17,14 @@
 package org.apache.wicket.behavior;
 
 import org.apache.wicket.ResourceReference;
-import org.apache.wicket.markup.html.CSSPackageResource;
-import org.apache.wicket.markup.html.IHeaderContributor;
-import org.apache.wicket.markup.html.JavascriptPackageResource;
 
 /**
- * A {@link org.apache.wicket.behavior.AbstractHeaderContributor} behavior that is specialized on
- * package resources. If you use this class, you have to pre-register the resources you want to
- * contribute. A shortcut for common cases is to call {@link #forCss(Class, String)} to contribute a
- * package css file or {@link #forJavaScript(Class, String)} to contribute a packaged javascript
- * file. For instance:
- * 
- * <pre>
- * add(HeaderContributor.forCss(MyPanel.class, &quot;mystyle.css&quot;));
- * </pre>
+ * A bunch of static helper methods to add CSS and Javascript to the markup headers
  * 
  * @author Eelco Hillenius
  * @author Matej Knopp
  */
-public class HeaderContributor extends AbstractHeaderContributor
+public class HeaderContributor
 {
 	private static final long serialVersionUID = 1L;
 
@@ -50,9 +39,9 @@
 	 *            The path
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forCss(final Class<?> scope, final String path)
+	public static final AbstractHeaderContributor forCss(final Class<?> scope, final String path)
 	{
-		return CSSPackageResource.getHeaderContribution(scope, path);
+		return new CssHeaderContributor(scope, path);
 	}
 
 	/**
@@ -68,10 +57,10 @@
 	 *            The media type for this CSS ("print", "screen", etc.)
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forCss(final Class<?> scope, final String path,
+	public static final AbstractHeaderContributor forCss(final Class<?> scope, final String path,
 		final String media)
 	{
-		return CSSPackageResource.getHeaderContribution(scope, path, media);
+		return new CssHeaderContributor(scope, path, media);
 	}
 
 	/**
@@ -82,9 +71,9 @@
 	 * 
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forCss(final ResourceReference reference)
+	public static final AbstractHeaderContributor forCss(final ResourceReference reference)
 	{
-		return CSSPackageResource.getHeaderContribution(reference);
+		return new CssReferenceHeaderContributor(reference);
 	}
 
 	/**
@@ -96,10 +85,10 @@
 	 *            The media type for this CSS ("print", "screen", etc.)
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forCss(final ResourceReference reference,
+	public static final AbstractHeaderContributor forCss(final ResourceReference reference,
 		final String media)
 	{
-		return CSSPackageResource.getHeaderContribution(reference, media);
+		return new CssReferenceHeaderContributor(reference, media);
 	}
 
 	/**
@@ -116,9 +105,9 @@
 	 *            The location of the css file.
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forCss(final String location)
+	public static final AbstractHeaderContributor forCss(final String location)
 	{
-		return CSSPackageResource.getHeaderContribution(location);
+		return new CssLocationHeaderContributor(location);
 	}
 
 	/**
@@ -137,9 +126,9 @@
 	 *            The media type for this CSS ("print", "screen", etc.)
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forCss(final String location, final String media)
+	public static final AbstractHeaderContributor forCss(final String location, final String media)
 	{
-		return CSSPackageResource.getHeaderContribution(location, media);
+		return new CssLocationHeaderContributor(location, media);
 	}
 
 	/**
@@ -153,9 +142,10 @@
 	 *            The path
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forJavaScript(final Class<?> scope, final String path)
+	public static final AbstractHeaderContributor forJavaScript(final Class<?> scope,
+		final String path)
 	{
-		return JavascriptPackageResource.getHeaderContribution(scope, path);
+		return new JavascriptHeaderContributor(scope, path);
 	}
 
 	/**
@@ -166,9 +156,9 @@
 	 * 
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forJavaScript(final ResourceReference reference)
+	public static final AbstractHeaderContributor forJavaScript(final ResourceReference reference)
 	{
-		return JavascriptPackageResource.getHeaderContribution(reference);
+		return new JavascriptReferenceHeaderContributor(reference);
 	}
 
 	/**
@@ -185,37 +175,15 @@
 	 *            The location of the java script file.
 	 * @return the new header contributor instance
 	 */
-	public static final HeaderContributor forJavaScript(final String location)
-	{
-		return JavascriptPackageResource.getHeaderContribution(location);
-	}
-
-	/**
-	 * Resource reference to contribute.
-	 */
-	private IHeaderContributor headerContributor = null;
-
-	/**
-	 * Construct.
-	 * 
-	 * @param headerContributor
-	 *            the header contributor
-	 */
-	public HeaderContributor(IHeaderContributor headerContributor)
+	public static final AbstractHeaderContributor forJavaScript(final String location)
 	{
-		if (headerContributor == null)
-		{
-			throw new IllegalArgumentException("header contributor may not be null");
-		}
-		this.headerContributor = headerContributor;
+		return new JavascriptLocationHeaderContributor(location);
 	}
 
 	/**
-	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#getHeaderContributors()
+	 * No need to instantiate
 	 */
-	@Override
-	public final IHeaderContributor[] getHeaderContributors()
+	private HeaderContributor()
 	{
-		return new IHeaderContributor[] { headerContributor };
 	}
 }
\ No newline at end of file

Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptHeaderContributor.java?rev=890032&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptHeaderContributor.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.markup.html.resources.JavascriptResourceReference;
+
+/**
+ * @author Juergen Donnerstag
+ */
+public class JavascriptHeaderContributor extends AbstractHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	private final Class<?> scope;
+	private final String path;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param scope
+	 *            The scope of the package resource (typically the class of the caller, or a class
+	 *            that lives in the package where the resource lives).
+	 * @param path
+	 *            The path
+	 */
+	public JavascriptHeaderContributor(final Class<?> scope, final String path)
+	{
+		this.scope = scope;
+		this.path = path;
+	}
+
+	/**
+	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 */
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		response.renderJavascriptReference(new JavascriptResourceReference(scope, path));
+	}
+}

Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptLocationHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptLocationHeaderContributor.java?rev=890032&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptLocationHeaderContributor.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptLocationHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+
+/**
+ * Returns a new instance of a header contributor referencing a CSS file using one of the following
+ * schemes:
+ * <ul>
+ * <li>Starts with http:// or https:// for an external reference.</li>
+ * <li>Starts with "/" for an absolute reference that Wicket will not rewrite.</li>
+ * <li>Starts with anything else, which Wicket will automatically prepend to make relative to the
+ * context root of your web-app.</li>
+ * </ul>
+ * 
+ * @author Juergen Donnerstag
+ */
+public class JavascriptLocationHeaderContributor extends AbstractHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	private final String location;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param location
+	 *            The location of the css file.
+	 */
+	public JavascriptLocationHeaderContributor(final String location)
+	{
+		this.location = location;
+	}
+
+	/**
+	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 */
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		response.renderJavascriptReference(returnRelativePath(location));
+	}
+}

Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptReferenceHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptReferenceHeaderContributor.java?rev=890032&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptReferenceHeaderContributor.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/JavascriptReferenceHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.ResourceReference;
+import org.apache.wicket.markup.html.IHeaderResponse;
+
+/**
+ * @author Juergen Donnerstag
+ */
+public class JavascriptReferenceHeaderContributor extends AbstractHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	private final ResourceReference reference;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param reference
+	 */
+	public JavascriptReferenceHeaderContributor(final ResourceReference reference)
+	{
+		this.reference = reference;
+	}
+
+	/**
+	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 */
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		response.renderJavascriptReference(reference);
+	}
+}

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java Sun Dec 13 09:33:55 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.wicket.behavior;
 
-import org.apache.wicket.Component;
-import org.apache.wicket.markup.html.IHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
@@ -33,137 +31,77 @@
 {
 	private static final long serialVersionUID = 1L;
 
-	/** the contributor instance. */
-	private final StringContributor contributor;
+	/** The contribution as a model that returns a plain string. */
+	private final IModel<?> contribution;
 
 	/**
-	 * Simply writes out the string it was constructed with whenever it is called for a header
-	 * contribution.
+	 * Construct.
+	 * 
+	 * @param contribution
+	 *            The contribution as a plain string
 	 */
-	private static final class StringContributor implements IHeaderContributor
+	public StringHeaderContributor(final String contribution)
 	{
-		private static final long serialVersionUID = 1L;
-
-		/** The contribution as a model that returns a plain string. */
-		private final IModel<?> contribution;
-
-		/**
-		 * Construct.
-		 * 
-		 * @param contribution
-		 *            The contribution as a plain string
-		 */
-		public StringContributor(String contribution)
-		{
-			if (contribution == null)
-			{
-				throw new IllegalArgumentException("argument contribition must be not null");
-			}
-
-			this.contribution = new Model<String>(contribution);
-		}
-
-		/**
-		 * Construct.
-		 * 
-		 * @param contribution
-		 *            The contribution as a model that returns a plain string
-		 */
-		public StringContributor(IModel<?> contribution)
-		{
-			if (contribution == null)
-			{
-				throw new IllegalArgumentException("argument contribition must be not null");
-			}
-
-			this.contribution = contribution;
-		}
-
-		/**
-		 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
-		 */
-		public void renderHead(IHeaderResponse response)
-		{
-			Object object = contribution.getObject();
-			if (object != null)
-			{
-				response.getResponse().println(object.toString());
-			}
-		}
-
-		/**
-		 * @see java.lang.Object#hashCode()
-		 */
-		@Override
-		public int hashCode()
+		if (contribution == null)
 		{
-			Object object = contribution.getObject();
-			return (object != null) ? object.hashCode() : 0;
+			throw new IllegalArgumentException("argument contribition must be not null");
 		}
 
-		/**
-		 * @see java.lang.Object#equals(java.lang.Object)
-		 */
-		@Override
-		public boolean equals(Object obj)
-		{
-			if (obj instanceof StringContributor)
-			{
-				Object thisContrib = contribution.getObject();
-				Object thatContrib = ((StringContributor)obj).contribution.getObject();
-				return Objects.equal(thisContrib, thatContrib);
-			}
-			return false;
-		}
-
-		/**
-		 * @see java.lang.Object#toString()
-		 */
-		@Override
-		public String toString()
-		{
-			return "StringContributor[contribution=" + contribution + "]";
-		}
+		this.contribution = new Model<String>(contribution);
 	}
 
 	/**
 	 * Construct.
 	 * 
 	 * @param contribution
-	 *            header contribution as a plain string
+	 *            The contribution as a model that returns a plain string
 	 */
-	public StringHeaderContributor(String contribution)
+	public StringHeaderContributor(final IModel<?> contribution)
 	{
-		contributor = new StringContributor(contribution);
+		if (contribution == null)
+		{
+			throw new IllegalArgumentException("argument contribition must be not null");
+		}
+
+		this.contribution = contribution;
 	}
 
 	/**
-	 * Construct.
-	 * 
-	 * @param contribution
-	 *            header contribution as a model that returns a plain string
+	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 	 */
-	public StringHeaderContributor(IModel<?> contribution)
+	@Override
+	public void renderHead(IHeaderResponse response)
 	{
-		contributor = new StringContributor(contribution);
+		Object object = contribution.getObject();
+		if (object != null)
+		{
+			response.getResponse().println(object.toString());
+		}
 	}
 
 	/**
-	 * @see org.apache.wicket.behavior.AbstractHeaderContributor#getHeaderContributors()
+	 * @see java.lang.Object#hashCode()
 	 */
 	@Override
-	public final IHeaderContributor[] getHeaderContributors()
+	public int hashCode()
 	{
-		return new IHeaderContributor[] { contributor };
+		Object object = contribution.getObject();
+		return (object != null) ? object.hashCode() : 0;
 	}
 
 	/**
-	 * @see org.apache.wicket.behavior.AbstractBehavior#detach(org.apache.wicket.Component)
+	 * @see java.lang.Object#equals(java.lang.Object)
 	 */
 	@Override
-	public void detach(Component component)
+	public boolean equals(Object obj)
 	{
-		contributor.contribution.detach();
+		if (obj instanceof StringHeaderContributor)
+		{
+			Object thisContrib = contribution.getObject();
+			Object thatContrib = ((StringHeaderContributor)obj).contribution.getObject();
+			return Objects.equal(thisContrib, thatContrib);
+		}
+		return false;
 	}
 
 	/**
@@ -172,7 +110,6 @@
 	@Override
 	public String toString()
 	{
-		Object string = contributor.contribution.getObject();
-		return (string != null) ? string.toString() : "";
+		return "StringContributor[contribution=" + contribution + "]";
 	}
 }
\ No newline at end of file

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/JavascriptPackageResource.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/JavascriptPackageResource.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/JavascriptPackageResource.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/JavascriptPackageResource.java Sun Dec 13 09:33:55 2009
@@ -24,11 +24,7 @@
 import java.util.Locale;
 
 import org.apache.wicket.Application;
-import org.apache.wicket.RequestCycle;
-import org.apache.wicket.ResourceReference;
-import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.javascript.IJavascriptCompressor;
-import org.apache.wicket.markup.html.resources.JavascriptResourceReference;
 import org.apache.wicket.util.io.Streams;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
@@ -50,101 +46,6 @@
 	private static final Logger log = LoggerFactory.getLogger(JavascriptPackageResource.class);
 
 	/**
-	 * Returns a new instance of {@link HeaderContributor} with a header contributor that references
-	 * a java script file that lives in a package.
-	 * 
-	 * @param scope
-	 *            The scope of the package resource (typically the class of the caller, or a class
-	 *            that lives in the package where the resource lives).
-	 * @param path
-	 *            The path
-	 * @return the new header contributor instance
-	 */
-	public static final HeaderContributor getHeaderContribution(final Class<?> scope,
-		final String path)
-	{
-		return new HeaderContributor(new IHeaderContributor()
-		{
-			private static final long serialVersionUID = 1L;
-
-			public void renderHead(IHeaderResponse response)
-			{
-				response.renderJavascriptReference(new JavascriptResourceReference(scope, path));
-			}
-		});
-	}
-
-	/**
-	 * Returns a new instance of {@link HeaderContributor} with a header contributor that references
-	 * a java script file that lives in a package.
-	 * 
-	 * @param reference
-	 * 
-	 * @return the new header contributor instance
-	 */
-	public static final HeaderContributor getHeaderContribution(final ResourceReference reference)
-	{
-		return new HeaderContributor(new IHeaderContributor()
-		{
-			private static final long serialVersionUID = 1L;
-
-			public void renderHead(IHeaderResponse response)
-			{
-				response.renderJavascriptReference(reference);
-			}
-		});
-	}
-
-	/**
-	 * Returns a new instance of {@link HeaderContributor} with a header contributor referencing a
-	 * java script file using one of the following schemes:
-	 * <ul>
-	 * <li>Starts with http:// or https:// for an external reference.</li>
-	 * <li>Starts with "/" for an absolute reference that Wicket will not rewrite.</li>
-	 * <li>Starts with anything else, which Wicket will automatically prepend to make relative to
-	 * the context root of your web-app.</li>
-	 * </ul>
-	 * 
-	 * @param location
-	 *            The location of the java script file.
-	 * @return the new header contributor instance
-	 */
-	public static final HeaderContributor getHeaderContribution(final String location)
-	{
-		return new HeaderContributor(new IHeaderContributor()
-		{
-			private static final long serialVersionUID = 1L;
-
-			public void renderHead(IHeaderResponse response)
-			{
-				response.renderJavascriptReference(returnRelativePath(location));
-			}
-		});
-	}
-
-	/**
-	 * 
-	 * @param location
-	 * @return relative path
-	 */
-	private static final String returnRelativePath(String location)
-	{
-		// WICKET-59 allow external URLs, WICKET-612 allow absolute URLs.
-		if (location.startsWith("http://") || location.startsWith("https://") ||
-			location.startsWith("/"))
-		{
-			return location;
-		}
-		else
-		{
-			return RequestCycle.get()
-				.getProcessor()
-				.getRequestCodingStrategy()
-				.rewriteStaticRelativeUrl(location);
-		}
-	}
-
-	/**
 	 * Resource Stream that caches the stripped content.
 	 * 
 	 * @author Matej Knopp

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/WebPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/WebPage.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/WebPage.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/WebPage.java Sun Dec 13 09:33:55 2009
@@ -87,7 +87,6 @@
 		/**
 		 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(IHeaderResponse)
 		 */
-		@Override
 		public final void renderHead(final IHeaderResponse headResponse)
 		{
 			// TODO

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java Sun Dec 13 09:33:55 2009
@@ -32,9 +32,10 @@
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.ResourceReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.behavior.IBehavior;
+import org.apache.wicket.behavior.JavascriptReferenceHeaderContributor;
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.JavascriptPackageResource;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
 import org.apache.wicket.markup.html.list.AbstractItem;
@@ -1274,7 +1275,7 @@
 		itemContainer = new TreeItemContainer("i");
 		add(itemContainer);
 
-		add(JavascriptPackageResource.getHeaderContribution(JAVASCRIPT));
+		add(HeaderContributor.forJavaScript(JAVASCRIPT));
 
 		checkModel();
 	}

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/BaseTree.java Sun Dec 13 09:33:55 2009
@@ -27,8 +27,9 @@
 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
 import org.apache.wicket.behavior.AbstractBehavior;
+import org.apache.wicket.behavior.CssReferenceHeaderContributor;
+import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.CSSPackageResource;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.markup.html.resources.CompressedResourceReference;
@@ -69,7 +70,7 @@
 		ResourceReference css = getCSS();
 		if (css != null)
 		{
-			add(CSSPackageResource.getHeaderContribution(css));
+			add(HeaderContributor.forCss(css));
 		}
 	}
 

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_13.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_13.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_13.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_13.java Sun Dec 13 09:33:55 2009
@@ -20,7 +20,7 @@
 import org.apache.wicket.Component;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.behavior.HeaderContributor;
+import org.apache.wicket.behavior.CssLocationHeaderContributor;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.model.Model;
 
@@ -53,6 +53,6 @@
 		add(header);
 
 		// HeaderContributions must work with <html> components in place as well
-		add(HeaderContributor.forCss("BasePage.css"));
+		add(new CssLocationHeaderContributor("BasePage.css"));
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_15.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_15.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_15.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimplePage_15.java Sun Dec 13 09:33:55 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.wicket.markup.html.basic;
 
-import org.apache.wicket.behavior.HeaderContributor;
+import org.apache.wicket.behavior.CssLocationHeaderContributor;
 import org.apache.wicket.markup.html.WebPage;
 
 
@@ -34,6 +34,6 @@
 	 */
 	public SimplePage_15()
 	{
-		add(HeaderContributor.forCss("BasePage.css"));
+		add(new CssLocationHeaderContributor("BasePage.css"));
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/header/MyPage2.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/header/MyPage2.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/header/MyPage2.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/header/MyPage2.java Sun Dec 13 09:33:55 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.wicket.markup.html.header;
 
-import org.apache.wicket.markup.html.CSSPackageResource;
+import org.apache.wicket.behavior.CssHeaderContributor;
 import org.apache.wicket.markup.html.WebPage;
 
 /**
@@ -32,8 +32,6 @@
 	public MyPage2()
 	{
 		// And it is not problem if historically it has been added. Wicket will render it just once
-		add(CSSPackageResource.getHeaderContribution(this.getClass(), this.getClass()
-			.getSimpleName() +
-			".css"));
+		add(new CssHeaderContributor(this.getClass(), this.getClass().getSimpleName() + ".css"));
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java?rev=890032&r1=890031&r2=890032&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java Sun Dec 13 09:33:55 2009
@@ -17,7 +17,7 @@
 package org.apache.wicket.markup.resolver;
 
 import org.apache.wicket.PageParameters;
-import org.apache.wicket.markup.html.CSSPackageResource;
+import org.apache.wicket.behavior.CssHeaderContributor;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.basic.Label;
 
@@ -42,6 +42,6 @@
 		add(new Label("message",
 			"If you see this message wicket is properly configured and running"));
 
-		add(CSSPackageResource.getHeaderContribution(HomePage_2.class, "main.css"));
+		add(new CssHeaderContributor(HomePage_2.class, "main.css"));
 	}
 }