You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by at...@apache.org on 2007/06/14 17:08:58 UTC

svn commit: r547273 - in /incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket: RenderContext.java protocol/http/WicketFilter.java

Author: ate
Date: Thu Jun 14 08:08:57 2007
New Revision: 547273

URL: http://svn.apache.org/viewvc?view=rev&rev=547273
Log:
WICKET-650: New Wicket Portlet support: use a RenderContext for abstracted url generation, writing header response and namespacing
See: https://issues.apache.org/jira/browse/WICKET-650

Added:
    incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java   (with props)
Modified:
    incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java

Added: incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java?view=auto&rev=547273
==============================================================================
--- incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java (added)
+++ incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java Thu Jun 14 08:08:57 2007
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+
+/**
+ * @author Ate Douma
+ */
+public class RenderContext
+{
+	/** Thread-local that holds the current request cycle. */
+	private static final ThreadLocal current = new ThreadLocal();
+	
+	public RenderContext()
+	{
+		set(this);
+	}
+	
+	public static final RenderContext get()
+	{
+		RenderContext context = (RenderContext)current.get();
+		if (context == null)
+		{
+			context = new RenderContext();
+		}
+		return context;
+	}
+	
+	protected static final void set(RenderContext context)
+	{
+		current.set(context);
+	}
+
+	public CharSequence getNamespace()
+	{
+		return "";
+	}
+	
+	public String encodeMarkupId(String markupId)
+	{
+		return markupId;
+	}
+	
+	public CharSequence encodeActionURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public CharSequence encodeRenderURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public CharSequence encodeResourceURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public CharSequence encodeSharedResourceURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public IHeaderResponse getHeaderResponse()
+	{
+		return null;
+	}
+	
+	public boolean isEmbedded()
+	{
+		return false;
+	}
+}

Propchange: incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RenderContext.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java?view=diff&rev=547273&r1=547272&r2=547273
==============================================================================
--- incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java (original)
+++ incubator/wicket/branches/wicket-1.3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java Thu Jun 14 08:08:57 2007
@@ -32,6 +32,7 @@
 
 import org.apache.wicket.AbortException;
 import org.apache.wicket.Application;
+import org.apache.wicket.RenderContext;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Resource;
 import org.apache.wicket.Session;
@@ -244,6 +245,7 @@
 			response.setCharacterEncoding(webApplication.getRequestCycleSettings()
 					.getResponseRequestEncoding());
 
+            createRenderContext(request, response);
 			try
 			{
 				// Create request cycle
@@ -707,4 +709,9 @@
 		}
 		return -1;
 	}
+
+    protected void createRenderContext(WebRequest request, WebResponse response)
+    {
+        new RenderContext();
+    }
 }