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

svn commit: r570046 - in /wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http: WicketFilter.java WicketServlet.java

Author: knopp
Date: Mon Aug 27 02:06:08 2007
New Revision: 570046

URL: http://svn.apache.org/viewvc?rev=570046&view=rev
Log:
WICKET-878

Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java?rev=570046&r1=570045&r2=570046&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java Mon Aug 27 02:06:08 2007
@@ -116,7 +116,7 @@
 		if (isWicketRequest(relativePath))
 		{
 			HttpServletResponse httpServletResponse = (HttpServletResponse)response;
-			long lastModified = getLastModified(httpServletRequest);
+			long lastModified = getLastModified(httpServletRequest, httpServletResponse);
 			if (lastModified == -1)
 			{
 				// servlet doesn't support if-modified-since, no reason
@@ -205,8 +205,12 @@
 				}
 			}
 
+			final RequestCycle existingRequestCycle = RequestCycle.get();
+
 			// Create a new webrequest
-			final WebRequest request = webApplication.newWebRequest(servletRequest);
+			final WebRequest request = existingRequestCycle != null
+					? (WebRequest)existingRequestCycle.getRequest()
+					: webApplication.newWebRequest(servletRequest);
 
 			// Are we using REDIRECT_TO_BUFFER?
 			if (webApplication.getRequestCycleSettings().getRenderStrategy() == IRequestCycleSettings.REDIRECT_TO_BUFFER)
@@ -244,7 +248,9 @@
 
 			// Create a response object and set the output encoding according to
 			// wicket's application setttings.
-			final WebResponse response = webApplication.newWebResponse(servletResponse);
+			final WebResponse response = existingRequestCycle != null
+					? (WebResponse)existingRequestCycle.getResponse()
+					: webApplication.newWebResponse(servletResponse);
 			response.setAjax(request.isAjax());
 			response.setCharacterEncoding(webApplication.getRequestCycleSettings()
 					.getResponseRequestEncoding());
@@ -252,7 +258,9 @@
 			try
 			{
 				// Create request cycle
-				RequestCycle cycle = webApplication.newRequestCycle(request, response);
+				RequestCycle cycle = existingRequestCycle != null
+						? existingRequestCycle
+						: webApplication.newRequestCycle(request, response);
 
 				try
 				{
@@ -692,12 +700,14 @@
 	/**
 	 * Gets the last modified time stamp for the given request.
 	 * 
-	 * @param request
+	 * @param servletRequest
+	 * @param servletResponse
 	 * @return The last modified time stamp
 	 */
-	long getLastModified(final HttpServletRequest request)
+	long getLastModified(final HttpServletRequest servletRequest,
+			final HttpServletResponse servletResponse)
 	{
-		final String pathInfo = getRelativePath(request);
+		final String pathInfo = getRelativePath(servletRequest);
 
 		if (pathInfo.startsWith(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX))
 		{
@@ -705,6 +715,10 @@
 			final String resourceReferenceKey = pathInfo
 					.substring(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX.length());
 
+			final WebRequest request = webApplication.newWebRequest(servletRequest);
+			final WebResponse response = webApplication.newWebResponse(servletResponse);
+			RequestCycle cycle = webApplication.newRequestCycle(request, response);
+
 			// Try to find shared resource
 			Resource resource = webApplication.getSharedResources().get(resourceReferenceKey);
 
@@ -715,10 +729,8 @@
 				{
 					Application.set(webApplication);
 
-					final WebRequest webRequest = webApplication.newWebRequest(request);
-
 					// Set parameters from servlet request
-					resource.setParameters(webRequest.getParameterMap());
+					resource.setParameters(request.getParameterMap());
 
 					// Get resource stream
 					IResourceStream stream = resource.getResourceStream();

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java?rev=570046&r1=570045&r2=570046&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java Mon Aug 27 02:06:08 2007
@@ -33,11 +33,10 @@
  * 
  * Please use {@link WicketFilter} if you require advanced chaining of resources.
  * 
- * Servlet class for all wicket applications. The specific application class to
- * instantiate should be specified to the application server via an init-params
- * argument named "applicationClassName" in the servlet declaration, which is
- * typically in a <i>web.xml </i> file. The servlet declaration may vary from
- * one application server to another, but should look something like this:
+ * Servlet class for all wicket applications. The specific application class to instantiate should
+ * be specified to the application server via an init-params argument named "applicationClassName"
+ * in the servlet declaration, which is typically in a <i>web.xml </i> file. The servlet declaration
+ * may vary from one application server to another, but should look something like this:
  * 
  * <pre>
  * &lt;servlet&gt;
@@ -51,13 +50,11 @@
  * &lt;/servlet&gt;
  * </pre>
  * 
- * Note that the applicationClassName parameter you specify must be the fully
- * qualified name of a class that extends WebApplication. If your class cannot
- * be found, does not extend WebApplication or cannot be instantiated, a runtime
- * exception of type WicketRuntimeException will be thrown.
+ * Note that the applicationClassName parameter you specify must be the fully qualified name of a
+ * class that extends WebApplication. If your class cannot be found, does not extend WebApplication
+ * or cannot be instantiated, a runtime exception of type WicketRuntimeException will be thrown.
  * </p>
- * As an alternative, you can configure an application factory instead. This
- * looks like:
+ * As an alternative, you can configure an application factory instead. This looks like:
  * 
  * <pre>
  * &lt;init-param&gt;
@@ -66,18 +63,16 @@
  * &lt;/init-param&gt;
  * </pre>
  * 
- * and it has to satisfy interface
- * {@link org.apache.wicket.protocol.http.IWebApplicationFactory}.
+ * and it has to satisfy interface {@link org.apache.wicket.protocol.http.IWebApplicationFactory}.
  * 
  * <p>
- * When GET/POST requests are made via HTTP, a WebRequestCycle object is
- * created from the request, response and session objects (after wrapping them
- * in the appropriate wicket wrappers). The RequestCycle's render() method is
- * then called to produce a response to the HTTP request.
+ * When GET/POST requests are made via HTTP, a WebRequestCycle object is created from the request,
+ * response and session objects (after wrapping them in the appropriate wicket wrappers). The
+ * RequestCycle's render() method is then called to produce a response to the HTTP request.
  * <p>
- * If you want to use servlet specific configuration, e.g. using init parameters
- * from the {@link javax.servlet.ServletConfig}object, you should override the
- * init() method of {@link javax.servlet.GenericServlet}. For example:
+ * If you want to use servlet specific configuration, e.g. using init parameters from the
+ * {@link javax.servlet.ServletConfig}object, you should override the init() method of
+ * {@link javax.servlet.GenericServlet}. For example:
  * 
  * <pre>
  * public void init() throws ServletException
@@ -88,9 +83,9 @@
  * </pre>
  * 
  * </p>
- * In order to support frameworks like Spring, the class is non-final and the
- * variable webApplication is protected instead of private. Thus subclasses may
- * provide their own means of providing the application object.
+ * In order to support frameworks like Spring, the class is non-final and the variable
+ * webApplication is protected instead of private. Thus subclasses may provide their own means of
+ * providing the application object.
  * 
  * @see org.apache.wicket.RequestCycle
  * @author Jonathan Locke
@@ -191,7 +186,7 @@
 	}
 
 	/**
-	 * @return The wicket filter 
+	 * @return The wicket filter
 	 */
 	protected WicketFilter newWicketFilter()
 	{
@@ -212,6 +207,9 @@
 	 */
 	protected long getLastModified(final HttpServletRequest servletRequest)
 	{
-		return wicketFilter.getLastModified(servletRequest);
+		// Right now I don't see any other way. wicketFilter.getLastModified takes now also
+		// servletResponse, which we don't have at this point
+		return -1;
+		// return wicketFilter.getLastModified(servletRequest);
 	}
 }