You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2011/04/23 10:29:39 UTC

svn commit: r1096121 - in /wicket/trunk/wicket-core/src: main/java/org/apache/wicket/markup/html/panel/ main/java/org/apache/wicket/markup/html/tree/ test/java/org/apache/wicket/markup/html/tree/

Author: jdonnerstag
Date: Sat Apr 23 08:29:39 2011
New Revision: 1096121

URL: http://svn.apache.org/viewvc?rev=1096121&view=rev
Log:
fixed: Tree 1.4 to 1.5 migration issue warning

Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
    wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/tree/TreeTest.java

Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java?rev=1096121&r1=1096120&r2=1096121&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java Sat Apr 23 08:29:39 2011
@@ -22,6 +22,7 @@ import org.apache.wicket.markup.Componen
 import org.apache.wicket.markup.IMarkupFragment;
 import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
+import org.apache.wicket.markup.html.list.AbstractItem;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -94,6 +95,42 @@ public final class DefaultMarkupSourcing
 			return markup;
 		}
 
+		// This is to make migration for Items from 1.4 to 1.5 more easy
+		if (Character.isDigit(child.getId().charAt(0)))
+		{
+			String id = child.getId();
+			boolean miss = false;
+			for (int i = 1; i < id.length(); i++)
+			{
+				if (Character.isDigit(id.charAt(i)) == false)
+				{
+					miss = true;
+					break;
+				}
+			}
+
+			if (miss == false)
+			{
+				// The LoopItems markup is equal to the Loops markup
+				markup = container.getMarkup();
+
+				if (!(child instanceof AbstractItem) && log.isWarnEnabled())
+				{
+					log.warn("1.4 to 1.5 migration issue: the childs wicket-id contains decimals only. " +
+						"By convention that +" +
+						"is only the case for children (Items) of Loop, ListView, " +
+						"Tree etc.. To avoid the warning, the childs container should implement:\n" +
+						"@Override public IMarkupFragment getMarkup(Component child) {\n" +
+						"// The childs markup is always equal to the parents markup.\n" +
+						"return getMarkup(); }\n" +
+						"Child: " +
+						child.toString() +
+						"\nContainer: " +
+						container.toString());
+				}
+			}
+		}
+
 		return markup;
 	}
 

Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java?rev=1096121&r1=1096120&r2=1096121&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java Sat Apr 23 08:29:39 2011
@@ -35,6 +35,7 @@ import org.apache.wicket.MarkupContainer
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
 import org.apache.wicket.markup.html.IHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -426,6 +427,13 @@ public abstract class AbstractTree exten
 				visitItemAndChildren(rootItem, callback);
 			}
 		}
+
+		@Override
+		public IMarkupFragment getMarkup(final Component child)
+		{
+			// The childs markup is always equal to the parents markup.
+			return getMarkup();
+		}
 	}
 
 	private boolean attached = false;

Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/tree/TreeTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/tree/TreeTest.java?rev=1096121&r1=1096120&r2=1096121&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/tree/TreeTest.java (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/tree/TreeTest.java Sat Apr 23 08:29:39 2011
@@ -70,6 +70,8 @@ public class TreeTest extends WicketTest
 	/** */
 	public static class TestPage extends WebPage implements IMarkupResourceStreamProvider
 	{
+		private static final long serialVersionUID = 1L;
+
 		AbstractTree tree;
 		DefaultTreeModel treeModel;
 		DefaultMutableTreeNode rootNode;