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 2008/09/14 23:36:34 UTC

svn commit: r695294 - in /wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket: ./ request/handler/ request/handler/impl/

Author: knopp
Date: Sun Sep 14 14:36:34 2008
New Revision: 695294

URL: http://svn.apache.org/viewvc?rev=695294&view=rev
Log:
is this too crazy??

Added:
    wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IComponent.java   (with props)
    wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IPage.java   (with props)
    wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageRequestHandler.java   (contents, props changed)
      - copied, changed from r695290, wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageInstanceRequestHandler.java
Removed:
    wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageInstanceRequestHandler.java
Modified:
    wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/impl/RenderPageRequestHandler.java

Added: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IComponent.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IComponent.java?rev=695294&view=auto
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IComponent.java (added)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IComponent.java Sun Sep 14 14:36:34 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.model.IDetachable;
+
+/**
+ * Base interface for components. The purpose of this interface is to make certain parts of Wicket
+ * easier to mock and unit test.
+ * 
+ * @author Matej Knopp
+ */
+// TODO: Better name would be nice
+public interface IComponent extends IDetachable
+{
+	/**
+	 * Gets this component's path.
+	 * 
+	 * @return Colon separated path to this component in the component hierarchy
+	 */
+	public String getPath();
+
+	/**
+	 * Gets the id of this component.
+	 * 
+	 * @return The id of this component
+	 */
+	public String getId();
+
+	/**
+	 * Retrieves id by which this component is represented within the markup. This is either the id
+	 * attribute set explicitly via a call to {@link #setMarkupId(String)}, id attribute defined in
+	 * the markup, or an automatically generated id - in that order.
+	 * <p>
+	 * If no id is set and <code>createIfDoesNotExist</code> is false, this method will return
+	 * null. Otherwise it will generate an id value that will be unique in the page. This is the
+	 * preferred way as there is no chance of id collision.
+	 * <p>
+	 * Note: This method should only be called after the component or its parent have been added to
+	 * the page.
+	 * 
+	 * @param createIfDoesNotExist
+	 *            When there is no existing markup id, determines whether it should be generated or
+	 *            whether <code>null</code> should be returned.
+	 * 
+	 * @return markup id of the component
+	 */
+	public String getMarkupId(boolean createIfDoesNotExist);
+	
+	/**
+	 * Gets the component at the given path.
+	 * 
+	 * @param path
+	 *            Path to component
+	 * @return The component at the path
+	 */
+	public IComponent get(String path);
+}

Propchange: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IComponent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IPage.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IPage.java?rev=695294&view=auto
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IPage.java (added)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IPage.java Sun Sep 14 14:36:34 2008
@@ -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;
+
+/**
+ * Base interface for pages. The purpose of this interface is to make certain parts of Wicket easier
+ * to mock and unit test.
+ * 
+ * @author Matej Knopp
+ */
+// TODO: Better name would be nice
+public interface IPage extends IComponent
+{
+	/**
+	 * @return A stable identifier for this page map entry
+	 */
+	public int getNumericId();
+
+	/**
+	 * @return The current version number of this page. If the page has been changed once, the
+	 *         return value will be 1. If the page has not yet been revised, the version returned
+	 *         will be 0, indicating that the page is still in its original state.
+	 */
+	public int getCurrentVersionNumber();
+
+	/**
+	 * @return String The PageMap name
+	 */
+	public String getPageMapName();
+	
+	/**
+	 * Renders the page 
+	 */
+	public void renderPage();
+}

Propchange: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/IPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageRequestHandler.java (from r695290, wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageInstanceRequestHandler.java)
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageRequestHandler.java?p2=wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageRequestHandler.java&p1=wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageInstanceRequestHandler.java&r1=695290&r2=695294&rev=695294&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageInstanceRequestHandler.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageRequestHandler.java Sun Sep 14 14:36:34 2008
@@ -16,10 +16,20 @@
  */
 package org.apache._wicket.request.handler;
 
+import org.apache._wicket.IPage;
 import org.apache._wicket.request.RequestHandler;
-import org.apache.wicket.Page;
 
-public interface PageInstanceRequestHandler extends RequestHandler
+/**
+ * Request handler that works with a page instance.
+ * 
+ * @author Matej Knopp
+ */
+public interface PageRequestHandler extends RequestHandler
 {
-	public Page getPageInstance();
+	/**
+	 * Returns the page
+	 * 
+	 * @return page instance
+	 */
+	public IPage getPage();
 }

Propchange: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/PageRequestHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/impl/RenderPageRequestHandler.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/impl/RenderPageRequestHandler.java?rev=695294&r1=695293&r2=695294&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/impl/RenderPageRequestHandler.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/_wicket/request/handler/impl/RenderPageRequestHandler.java Sun Sep 14 14:36:34 2008
@@ -16,15 +16,15 @@
  */
 package org.apache._wicket.request.handler.impl;
 
+import org.apache._wicket.IPage;
 import org.apache._wicket.RequestCycle;
 import org.apache._wicket.request.RequestHandler;
 import org.apache._wicket.request.Url;
-import org.apache._wicket.request.handler.PageInstanceRequestHandler;
+import org.apache._wicket.request.handler.PageRequestHandler;
 import org.apache._wicket.request.response.BufferedWebResponse;
 import org.apache._wicket.request.response.Response;
 import org.apache._wicket.request.response.WebResponse;
 import org.apache.wicket.Application;
-import org.apache.wicket.Page;
 import org.apache.wicket.settings.IRequestCycleSettings;
 
 /**
@@ -34,9 +34,9 @@
  * 
  * @author Matej Knopp
  */
-public class RenderPageRequestHandler implements PageInstanceRequestHandler
+public class RenderPageRequestHandler implements PageRequestHandler
 {
-	private final Page page;
+	private final IPage page;
 	private final boolean preventRedirect;
 
 	/**
@@ -44,7 +44,7 @@
 	 * 
 	 * @param page
 	 */
-	public RenderPageRequestHandler(Page page)
+	public RenderPageRequestHandler(IPage page)
 	{
 		this(page, false);
 	}
@@ -58,7 +58,7 @@
 	 *            <code>false</code> a redirect will be issued if required by the request
 	 *            strategy.
 	 */
-	public RenderPageRequestHandler(Page page, boolean preventRedirect)
+	public RenderPageRequestHandler(IPage page, boolean preventRedirect)
 	{
 		if (page == null)
 		{
@@ -68,7 +68,7 @@
 		this.page = page;
 	}
 
-	public Page getPageInstance()
+	public IPage getPage()
 	{
 		return page;
 	}
@@ -133,7 +133,7 @@
 		try
 		{
 			requestCycle.setResponse(response);
-			page.render();
+			page.renderPage();
 			return response;
 		}
 		finally