You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2008/05/08 00:21:06 UTC

svn commit: r654304 - in /wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src: main/java/org/apache/wicket/markup/ test/java/org/apache/wicket/markup/

Author: jcompagner
Date: Wed May  7 15:21:02 2008
New Revision: 654304

URL: http://svn.apache.org/viewvc?rev=654304&view=rev
Log:
WICKET-1507 MarkupCache style/variation/locale support broken

Added:
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style1.html
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style2.html
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style1.html
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style2.html
Modified:
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/Markup.java
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceData.java
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceTest.java

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/Markup.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/Markup.java?rev=654304&r1=654303&r2=654304&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/Markup.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/Markup.java Wed May  7 15:21:02 2008
@@ -99,6 +99,19 @@
 	{
 		return markupResourceData;
 	}
+	
+	/**
+	 * Allowing the markup to return its own location allows special types of Markup
+	 * (i.e. MergedMarkup) to override their location, as they are composed of multiple
+	 * Markups in different locations.
+	 * SEE WICKET-1507 (Jeremy Thomerson)
+	 * @return the location of this markup
+	 */
+	public String locationAsString()
+	{
+		return markupResourceData.getResource().locationAsString();
+	}
+
 
 	/**
 	 * For Wicket it would be sufficient for this method to be package protected. However to allow

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=654304&r1=654303&r2=654304&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java Wed May  7 15:21:02 2008
@@ -435,6 +435,9 @@
 
 			if (cacheKey != null)
 			{
+				if (markup.locationAsString() != null) {
+					locationString = markup.locationAsString();
+				}
 				// add the markup to the cache.
 				markupKeyCache.put(cacheKey, locationString);
 				return putIntoCache(locationString, markup);

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceData.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceData.java?rev=654304&r1=654303&r2=654304&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceData.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceData.java Wed May  7 15:21:02 2008
@@ -40,8 +40,8 @@
 	/** The markup's resource stream */
 	private MarkupResourceStream resource;
 
-	/** In case of the inherited markup, the base markup's resource stream */
-	private MarkupResourceData baseMarkupResourceData;
+	/** In case of the inherited markup, this is the base markup */
+	private Markup baseMarkup;
 
 	/** If found in the markup, the <?xml ...?> string */
 	private String xmlDeclaration;
@@ -116,7 +116,7 @@
 	 */
 	public String getWicketNamespace()
 	{
-		return this.wicketNamespace;
+		return wicketNamespace;
 	}
 
 	/**
@@ -148,7 +148,7 @@
 	public final void setWicketNamespace(final String wicketNamespace)
 	{
 		this.wicketNamespace = wicketNamespace;
-		this.wicketId = wicketNamespace + ":id";
+		wicketId = wicketNamespace + ":id";
 
 		if (!ComponentTag.DEFAULT_WICKET_NAMESPACE.equals(wicketNamespace))
 		{
@@ -185,17 +185,29 @@
 	 */
 	public MarkupResourceData getBaseMarkupResourceData()
 	{
-		return this.baseMarkupResourceData;
+		if (baseMarkup == null)
+			return null;
+		return baseMarkup.getMarkupResourceData();
+	}
+
+	/**
+	 * In case of markup inheritance, the base markup.
+	 * 
+	 * @param baseMarkup
+	 *            The base markup
+	 */
+	public void setBaseMarkup(Markup baseMarkup)
+	{
+		this.baseMarkup = baseMarkup;
 	}
 
 	/**
 	 * In case of markup inheritance, the base markup resource.
 	 * 
-	 * @param baseMarkupResourceData
-	 *            The base markup resource
+	 * @return The base markup
 	 */
-	public void setBaseMarkupResourceData(MarkupResourceData baseMarkupResourceData)
+	public Markup getBaseMarkup()
 	{
-		this.baseMarkupResourceData = baseMarkupResourceData;
+		return baseMarkup;
 	}
 }
\ No newline at end of file

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java?rev=654304&r1=654303&r2=654304&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java Wed May  7 15:21:02 2008
@@ -68,7 +68,7 @@
 		getMarkupResourceData().setEncoding(markup.getMarkupResourceData().getEncoding());
 		getMarkupResourceData().setWicketNamespace(
 			markup.getMarkupResourceData().getWicketNamespace());
-		getMarkupResourceData().setBaseMarkupResourceData(baseMarkup.getMarkupResourceData());
+		getMarkupResourceData().setBaseMarkup(baseMarkup);
 
 		if (log.isDebugEnabled())
 		{
@@ -94,6 +94,17 @@
 		}
 	}
 
+	public String locationAsString()
+	{
+		/*
+		 * Uses both resource locations so that if the child does not have a style and the parent
+		 * does, the location is unique to this combination (or vice versa) SEE WICKET-1507 (Jeremy
+		 * Thomerson)
+		 */
+		return getMarkupResourceData().getBaseMarkup().locationAsString() + ":" +
+			getMarkupResourceData().getResource().locationAsString();
+	}
+
 	/**
 	 * Merge inherited and base markup.
 	 * 

Added: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style1.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style1.html?rev=654304&view=auto
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style1.html (added)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style1.html Wed May  7 15:21:02 2008
@@ -0,0 +1,3 @@
+  base: before (style1)
+  <wicket:child/>
+  base: after

Added: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style2.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style2.html?rev=654304&view=auto
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style2.html (added)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceBase_1_style2.html Wed May  7 15:21:02 2008
@@ -0,0 +1,3 @@
+  base: before (style2)
+  <wicket:child/>
+  base: after

Added: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style1.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style1.html?rev=654304&view=auto
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style1.html (added)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style1.html Wed May  7 15:21:02 2008
@@ -0,0 +1,5 @@
+  base: before (style1)
+  <wicket:child><wicket:extend>
+  extension: middle
+</wicket:extend></wicket:child>
+  base: after

Added: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style2.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style2.html?rev=654304&view=auto
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style2.html (added)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceExpectedResult_1_style2.html Wed May  7 15:21:02 2008
@@ -0,0 +1,5 @@
+  base: before (style2)
+  <wicket:child><wicket:extend>
+  extension: middle
+</wicket:extend></wicket:child>
+  base: after

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceTest.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceTest.java?rev=654304&r1=654303&r2=654304&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceTest.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceTest.java Wed May  7 15:21:02 2008
@@ -18,6 +18,7 @@
 
 import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.protocol.http.WebRequestCycle;
 import org.apache.wicket.util.diff.DiffUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,6 +42,31 @@
 	}
 
 	/**
+	 * TEST FOR WICKET-1507
+	 * @throws Exception
+	 */
+	public void testRenderChildPageWithStyleVariation() throws Exception
+	{
+		// first, render page with no style
+		executeTest(MarkupInheritanceExtension_1.class, "MarkupInheritanceExpectedResult_1.html");
+
+		// then, render with style1
+		tester.setupRequestAndResponse();
+		WebRequestCycle cycle = tester.createRequestCycle();
+		cycle.getSession().setStyle("style1");
+		tester.startPage(MarkupInheritanceExtension_1.class);
+		tester.assertRenderedPage(MarkupInheritanceExtension_1.class);
+		tester.assertResultPage(getClass(), "MarkupInheritanceExpectedResult_1_style1.html");
+
+		// then, render with style2
+		tester.setupRequestAndResponse();
+		cycle = tester.createRequestCycle();
+		cycle.getSession().setStyle("style2");
+		tester.startPage(MarkupInheritanceExtension_1.class);
+		tester.assertRenderedPage(MarkupInheritanceExtension_1.class);
+		tester.assertResultPage(getClass(), "MarkupInheritanceExpectedResult_1_style2.html");
+	}
+	/**
 	 * @throws Exception
 	 */
 	public void testRenderHomePage_1() throws Exception