You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/12/19 21:39:30 UTC

svn commit: r1050940 [1/2] - in /wicket/trunk/wicket-examples/src: main/java/org/apache/wicket/examples/resourcedecoration/ main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/ main/webapp/ main/webapp/WEB-INF/ test/java/org/apache/...

Author: mgrigorov
Date: Sun Dec 19 20:39:29 2010
New Revision: 1050940

URL: http://svn.apache.org/viewvc?rev=1050940&view=rev
Log:
Add example of resource aggregation.

developed-by: jthomerson
adapted-to-1.5-by: mgrigorov

Added:
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/BasicGroupingKey.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.css   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.html   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.js   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.css   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.js   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/app.css   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/footer.css   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/header.css   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/GroupLevel.java   (with props)
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/jquery-1.4.3.min.js   (with props)
Modified:
    wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml
    wicket/trunk/wicket-examples/src/main/webapp/index.html
    wicket/trunk/wicket-examples/src/test/java/org/apache/wicket/util/license/ApacheLicenceHeaderTest.java

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/BasicGroupingKey.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/BasicGroupingKey.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/BasicGroupingKey.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/BasicGroupingKey.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,111 @@
+/*
+ * 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.examples.resourcedecoration;
+
+import org.apache.wicket.examples.resourcedecoration.GroupedAndOrderedResourceReference.ResourceGroup;
+
+/**
+ * @author jthomerson
+ */
+public class BasicGroupingKey implements Comparable<BasicGroupingKey>
+{
+
+	private final ResourceGroup group;
+	private final int loadOrder;
+	private final boolean css;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param group
+	 * @param loadOrder
+	 * @param css
+	 */
+	public BasicGroupingKey(ResourceGroup group, int loadOrder, boolean css)
+	{
+		this.group = group;
+		this.loadOrder = loadOrder;
+		this.css = css;
+	}
+
+	public ResourceGroup getGroup()
+	{
+		return group;
+	}
+
+	public int getLoadOrder()
+	{
+		return loadOrder;
+	}
+
+	public boolean isCss()
+	{
+		return css;
+	}
+
+	@Override
+	public String toString()
+	{
+		return "BasicGroupingKey [group=" + group + ", loadOrder=" + loadOrder + ", css=" + css +
+			"]";
+	}
+
+	@Override
+	public int hashCode()
+	{
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + (css ? 1231 : 1237);
+		result = prime * result + ((group == null) ? 0 : group.hashCode());
+		result = prime * result + loadOrder;
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj)
+	{
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		BasicGroupingKey other = (BasicGroupingKey)obj;
+		if (css != other.css)
+			return false;
+		if (group != other.group)
+			return false;
+		if (loadOrder != other.loadOrder)
+			return false;
+		return true;
+	}
+
+	public int compareTo(BasicGroupingKey o)
+	{
+		int comp = css == o.css ? 0 : (css ? 1 : -1);
+		if (comp == 0)
+		{
+			comp = group.compareTo(o.group);
+		}
+		if (comp == 0)
+		{
+			comp = loadOrder < o.loadOrder ? -1 : (loadOrder == o.loadOrder ? 0 : 1);
+		}
+		return comp;
+	}
+
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/BasicGroupingKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.examples.resourcedecoration;
+
+import org.apache.wicket.request.resource.PackageResourceReference;
+
+public class GroupedAndOrderedResourceReference extends PackageResourceReference
+{
+
+	private static final long serialVersionUID = 1L;
+
+	public static enum ResourceGroup {
+		UNKNOWN, GLOBAL, APPLICATION, PAGE, COMPONENT
+	}
+
+	private final ResourceGroup group;
+	private final int loadOrder;
+
+	public GroupedAndOrderedResourceReference(ResourceGroup group, int loadOrder, Class<?> scope,
+		String name)
+	{
+		super(scope, name);
+		this.group = group;
+		this.loadOrder = loadOrder;
+	}
+
+	public GroupedAndOrderedResourceReference(ResourceGroup group, int loadOrder, String name)
+	{
+		super(name);
+		this.group = group;
+		this.loadOrder = loadOrder;
+	}
+
+	public ResourceGroup getGroup()
+	{
+		return group;
+	}
+
+	public int getLoadOrder()
+	{
+		return loadOrder;
+	}
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.css
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.css?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.css (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.css Sun Dec 19 20:39:29 2010
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+.borderedThing {
+	border: 1px solid red;	
+}
+
+.pending {
+	border: 1px solid yellow;
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.html?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.html (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.html Sun Dec 19 20:39:29 2010
@@ -0,0 +1,18 @@
+<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
+    <wicket:head>  
+        <title>Resource Aggregation Example Application</title>
+    </wicket:head>
+    <body>
+    	<h1 class="header">Resource Aggregation Example Application</h1>
+    	<p>If the body background is light grey, the app.css was loaded.</p>
+    	<p>If the h1 above has a dashed bottom border (and the one below has a dashed top border), header.css and footer.css were loaded.</p>
+    	<div wicket:id="jsProofPlaceholder" class="jsProofPlaceholder">
+    		placeholder that JS can do something with
+    	</div>
+    	<div wicket:id="ajaxProofPlaceholder" class="ajaxProofPlaceholder pending">
+    		after five seconds, you should see ajax update this container (to a green border)
+    	</div>
+    	<div class="complete">everything is done when all three boxes are green</div>
+    	<h1 class="footer">footer h1</h1>
+    </body>
+</html>

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,119 @@
+/*
+ * 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.examples.resourcedecoration;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.behavior.Behavior;
+import org.apache.wicket.examples.resourcedecoration.GroupedAndOrderedResourceReference.ResourceGroup;
+import org.apache.wicket.markup.html.IHeaderContributor;
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.resource.PackageResourceReference;
+import org.apache.wicket.util.time.Duration;
+
+/***/
+public class HomePage extends WebPage implements IHeaderContributor
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param parameters
+	 */
+	public HomePage(final PageParameters parameters)
+	{
+		final WebMarkupContainer jsPlaceholder = new WebMarkupContainer("jsProofPlaceholder");
+		jsPlaceholder.add(new Behavior()
+		{
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public void renderHead(Component component, IHeaderResponse response)
+			{
+				jsPlaceholder.setOutputMarkupId(true);
+				response.renderOnDomReadyJavaScript("$('#" + jsPlaceholder.getMarkupId() +
+					"').html('the ondomready script ran').css('border-color', 'green');");
+			}
+		});
+		add(jsPlaceholder);
+
+		add(new AjaxProofContainer("ajaxProofPlaceholder"));
+		add(new AbstractAjaxTimerBehavior(Duration.seconds(4))
+		{
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			protected void onTimer(AjaxRequestTarget target)
+			{
+				HomePage.this.replace(new AjaxProofContainer("ajaxProofPlaceholder"));
+				target.add(HomePage.this.get("ajaxProofPlaceholder"));
+				stop();
+			}
+		});
+	}
+
+	@Override
+	public void renderHead(IHeaderResponse response)
+	{
+		// example of things that may be shared for all your applications across your company,
+// etc...:
+		response.renderCSSReference(new GroupedAndOrderedResourceReference(ResourceGroup.GLOBAL, 0,
+			HomePage.class, "footer.css"));
+		response.renderCSSReference(new GroupedAndOrderedResourceReference(ResourceGroup.GLOBAL, 0,
+			HomePage.class, "header.css"));
+		response.renderJavaScriptReference(new GroupedAndOrderedResourceReference(
+			ResourceGroup.GLOBAL, 0, HomePage.class, "jquery-1.4.3.min.js"));
+		// example of something that may be in this single application:
+		response.renderCSSReference(new GroupedAndOrderedResourceReference(
+			ResourceGroup.APPLICATION, 0, HomePage.class, "app.css"));
+		// example of something that may be limited to certain pages:
+		response.renderCSSReference(new GroupedAndOrderedResourceReference(ResourceGroup.PAGE, 0,
+			HomePage.class, "HomePage.css"));
+		response.renderJavaScriptReference(new GroupedAndOrderedResourceReference(
+			ResourceGroup.PAGE, 0, HomePage.class, "HomePage.js"));
+	}
+
+	private static class AjaxProofContainer extends WebMarkupContainer
+		implements
+			IHeaderContributor
+	{
+		private static final long serialVersionUID = 1L;
+
+		public AjaxProofContainer(String id)
+		{
+			super(id);
+			setOutputMarkupId(true);
+		}
+
+		@Override
+		public void renderHead(IHeaderResponse response)
+		{
+			if (AjaxRequestTarget.get() != null)
+			{
+				response.renderCSSReference(new PackageResourceReference(HomePage.class, "ajax.css"));
+				response.renderJavaScriptReference(new PackageResourceReference(HomePage.class,
+					"ajax.js"));
+				response.renderOnDomReadyJavaScript("updatePending();");
+			}
+		}
+	}
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.js
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.js?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.js (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.js Sun Dec 19 20:39:29 2010
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+$(document).ready(function() {
+	$('.jsProofPlaceholder').addClass('borderedThing');
+});
\ No newline at end of file

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,199 @@
+/*
+ * 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.examples.resourcedecoration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.wicket.examples.resourcedecoration.GroupedAndOrderedResourceReference.ResourceGroup;
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.markup.html.WicketEventReference;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.resource.PackageResourceReference;
+import org.apache.wicket.request.resource.ResourceReference;
+import org.apache.wicket.resource.aggregation.AbstractResourceAggregatingHeaderResponse;
+import org.apache.wicket.resource.aggregation.ResourceReferenceAndStringData;
+
+
+public class HttpAggregatingHeaderResponse
+	extends
+	AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection, BasicGroupingKey>
+{
+
+	private static final BasicGroupingKey UNKNOWN_CSS_GROUPING_KEY = new BasicGroupingKey(
+		ResourceGroup.UNKNOWN, 0, true);
+	private static final BasicGroupingKey UNKNOWN_JS_GROUPING_KEY = new BasicGroupingKey(
+		ResourceGroup.UNKNOWN, 0, false);
+
+	// holder for all javascript blocks so that we can render them *after* the script tags
+	private List<Runnable> javascriptResponse = new ArrayList<Runnable>();
+
+	/**
+	 * Construct.
+	 * 
+	 * @param real
+	 */
+	public HttpAggregatingHeaderResponse(IHeaderResponse real)
+	{
+		super(real);
+	}
+
+	@Override
+	protected void renderCollection(Set<ResourceReferenceAndStringData> alreadyRendered,
+		BasicGroupingKey key, HttpAggregatingResourceReferenceCollection coll)
+	{
+		// for debugging:
+		getRealResponse().renderString("<!-- " + key + " -->\n");
+
+		// TODO: I'm not sure why yet, but our aggregator fails on wicket-event.js, so for now, we
+// skip aggregating all "UNKNOWN" references
+		if (ResourceGroup.UNKNOWN.equals(key.getGroup()))
+		{
+			super.renderCollection(alreadyRendered, key, coll);
+			return;
+		}
+
+		// build an aggregated URL:
+		StringBuffer refs = new StringBuffer();
+		boolean first = true;
+		for (ResourceReferenceAndStringData data : coll)
+		{
+			ResourceReference ref = data.getReference();
+			if (!first)
+			{
+				refs.append('|');
+			}
+			refs.append(ref.getScope().getName()).append(':').append(ref.getName());
+			first = false;
+		}
+
+		PageParameters parameters = new PageParameters();
+		parameters.add("refs", refs);
+		parameters.add("type", key.isCss() ? "css" : "js");
+		ResourceReference ref = new PackageResourceReference("merged-resources");
+		String url = RequestCycle.get().urlFor(ref, parameters).toString();
+		if (key.isCss())
+		{
+			getRealResponse().renderCSSReference(url);
+		}
+		else
+		{
+			getRealResponse().renderJavaScriptReference(url);
+		}
+	}
+
+	@Override
+	protected void onAllCollectionsRendered(
+		List<ResourceReferenceAndStringData> allTopLevelReferences)
+	{
+		super.onAllCollectionsRendered(allTopLevelReferences);
+
+		// TODO: you could also externalize these JS statements into a file that is loaded rather
+// than being inline in the HTML if you so desired
+		for (Runnable runnable : javascriptResponse)
+		{
+			runnable.run();
+		}
+		javascriptResponse = null;
+	}
+
+	@Override
+	protected HttpAggregatingResourceReferenceCollection newResourceReferenceCollection(
+		BasicGroupingKey key)
+	{
+		return new HttpAggregatingResourceReferenceCollection();
+	}
+
+	@Override
+	protected BasicGroupingKey newGroupingKey(ResourceReferenceAndStringData ref)
+	{
+		// THIS IS JUST A SIMPLE EXAMPLE. IN REALITY, YOU'LL ALMOST SURELY WANT TO ALSO GROUP BY
+// MEDIA TYPE FOR CSS.
+		if (ref.getReference() instanceof GroupedAndOrderedResourceReference)
+		{
+			GroupedAndOrderedResourceReference ourRef = (GroupedAndOrderedResourceReference)ref.getReference();
+			return new BasicGroupingKey(ourRef.getGroup(), ourRef.getLoadOrder(), ref.isCss());
+		}
+		return ref.isCss() ? UNKNOWN_CSS_GROUPING_KEY : UNKNOWN_JS_GROUPING_KEY;
+	}
+
+	@Override
+	public void renderJavaScript(final CharSequence javascript, final String id)
+	{
+		toJsResponse(new Runnable()
+		{
+			public void run()
+			{
+				getRealResponse().renderJavaScript(javascript, id);
+			}
+		});
+	}
+
+	@Override
+	public void renderOnDomReadyJavaScript(final String javascript)
+	{
+		super.renderJavaScriptReference(WicketEventReference.INSTANCE);
+		toJsResponse(new Runnable()
+		{
+			public void run()
+			{
+				getRealResponse().renderOnDomReadyJavaScript(javascript);
+			}
+		});
+	}
+
+	@Override
+	public void renderOnEventJavaScript(final String target, final String event,
+		final String javascript)
+	{
+		super.renderJavaScriptReference(WicketEventReference.INSTANCE);
+		toJsResponse(new Runnable()
+		{
+			public void run()
+			{
+				getRealResponse().renderOnEventJavaScript(target, event, javascript);
+			}
+		});
+	}
+
+	@Override
+	public void renderOnLoadJavaScript(final String javascript)
+	{
+		super.renderJavaScriptReference(WicketEventReference.INSTANCE);
+		toJsResponse(new Runnable()
+		{
+			public void run()
+			{
+				getRealResponse().renderOnLoadJavaScript(javascript);
+			}
+		});
+	}
+
+	private void toJsResponse(Runnable runnable)
+	{
+		javascriptResponse.add(runnable);
+// Response old = RequestCycle.get().setResponse(javascriptResponse);
+// try {
+// runnable.run();
+// } finally {
+// RequestCycle.get().setResponse(old);
+// }
+	}
+
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,27 @@
+/*
+ * 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.examples.resourcedecoration;
+
+import org.apache.wicket.resource.aggregation.ResourceReferenceCollection;
+
+public class HttpAggregatingResourceReferenceCollection extends ResourceReferenceCollection
+{
+	private static final long serialVersionUID = 1L;
+
+	// you could customize this collection class to have code specific to the collection, like
+// creating or rendering URLs, etc..
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.examples.resourcedecoration;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.resource.AbstractResource;
+import org.apache.wicket.util.lang.WicketObjects;
+import org.apache.wicket.util.resource.PackageResourceStream;
+
+public class MergedResourcesResource extends AbstractResource
+{
+	private static final long serialVersionUID = 1L;
+
+	@Override
+	protected ResourceResponse newResourceResponse(Attributes attributes)
+	{
+		PageParameters pageParameters = attributes.getParameters();
+		String refsVal = pageParameters.get("refs").toOptionalString();
+		String type = pageParameters.get("type").toOptionalString();
+		boolean isCss = "css".equals(type);
+
+		ResourceResponse resourceResponse = new ResourceResponse();
+
+		if (resourceResponse.dataNeedsToBeWritten(attributes))
+		{
+			if (isCss)
+			{
+				resourceResponse.setContentType("text/css");
+			}
+			else
+			{
+				resourceResponse.setContentType("text/javascript");
+			}
+
+			final StringBuilder combined = new StringBuilder();
+			String[] refs = refsVal.split("\\|");
+			for (String ref : refs)
+			{
+				String[] parts = ref.split(":");
+				String className = parts[0];
+				String name = parts[1];
+
+				PackageResourceStream resourceStream = new PackageResourceStream(
+					WicketObjects.resolveClass(className), name);
+				try
+				{
+					BufferedReader br = new BufferedReader(new InputStreamReader(
+						resourceStream.getInputStream()));
+					for (String line = br.readLine(); line != null; line = br.readLine())
+					{
+						combined.append(line).append("\n");
+					}
+				}
+				catch (Exception e)
+				{
+					combined.append("/* ERROR: ").append(e.getMessage()).append(" */\n");
+				}
+			}
+
+			resourceResponse.setWriteCallback(new WriteCallback()
+			{
+				@Override
+				public void writeData(Attributes attributes)
+				{
+					attributes.getResponse().write(combined);
+				}
+			});
+		}
+
+		return resourceResponse;
+	}
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java Sun Dec 19 20:39:29 2010
@@ -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.examples.resourcedecoration;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.markup.html.IHeaderResponseDecorator;
+import org.apache.wicket.protocol.http.WebApplication;
+
+
+public class ResourceDecorationApplication extends WebApplication
+{
+
+	@Override
+	protected void init()
+	{
+		super.init();
+
+		getSharedResources().add("merged-resources", new MergedResourcesResource());
+
+		setHeaderResponseDecorator(new IHeaderResponseDecorator()
+		{
+
+			public IHeaderResponse decorate(IHeaderResponse response)
+			{
+				// add one that aggregates http requests,
+				// but delegates writing of the scripts (or aggregated URL script and link tags) to
+// the real response
+
+				return new HttpAggregatingHeaderResponse(response);
+			}
+		});
+	}
+
+	@Override
+	public Class<HomePage> getHomePage()
+	{
+		return HomePage.class;
+	}
+
+	public static ResourceDecorationApplication get()
+	{
+		return (ResourceDecorationApplication)WebApplication.get();
+	}
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.css
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.css?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.css (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.css Sun Dec 19 20:39:29 2010
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+.complete {
+	border: 1px solid green;
+}
\ No newline at end of file

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.js
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.js?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.js (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.js Sun Dec 19 20:39:29 2010
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+function updatePending() {
+	$('.pending').addClass('complete');
+}
\ No newline at end of file

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ajax.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/app.css
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/app.css?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/app.css (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/app.css Sun Dec 19 20:39:29 2010
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+body {
+	background-color: #DEDEDE;
+}
\ No newline at end of file

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/app.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/footer.css
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/footer.css?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/footer.css (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/footer.css Sun Dec 19 20:39:29 2010
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+h1.footer {
+	border-top: 1px dashed black;
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/footer.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/header.css
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/header.css?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/header.css (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/header.css Sun Dec 19 20:39:29 2010
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+h1.header {
+	border-bottom: 1px dashed black;
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/header.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/GroupLevel.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/GroupLevel.java?rev=1050940&view=auto
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/GroupLevel.java (added)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/GroupLevel.java Sun Dec 19 20:39:29 2010
@@ -0,0 +1,24 @@
+/*
+ * 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.examples.resourcedecoration.httpaggregation;
+
+public enum GroupLevel implements Comparable<GroupLevel> {
+
+	// these sort in the order they are defined
+	UNKNOWN, GLOBAL, APPLICATION, PAGE, COMPONENT;
+
+}

Propchange: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/httpaggregation/GroupLevel.java
------------------------------------------------------------------------------
    svn:eol-style = native