You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2017/05/25 20:27:36 UTC

wicket git commit: WICKET-6377 Autolinking breaks hierarchy for nested elements

Repository: wicket
Updated Branches:
  refs/heads/master 5a228b314 -> 86b3abad1


WICKET-6377 Autolinking breaks hierarchy for nested elements

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/86b3abad
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/86b3abad
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/86b3abad

Branch: refs/heads/master
Commit: 86b3abad1fa2813c80c0c3fa73c4248cc4033301
Parents: 5a228b3
Author: Andrea Del Bene <ad...@apache.org>
Authored: Thu May 25 22:27:12 2017 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu May 25 22:28:45 2017 +0200

----------------------------------------------------------------------
 .../markup/resolver/AutoLinkResolver.java       | 39 +-------------------
 .../wicket/markup/html/link/AutolinkPage_6.html |  5 +++
 .../wicket/markup/html/link/AutolinkPage_6.java | 32 ++++++++++++++++
 .../wicket/markup/html/link/AutolinkTest.java   |  7 ++++
 4 files changed, 46 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/86b3abad/wicket-core/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
index 7ff5f87..8b462dd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
@@ -28,10 +28,10 @@ import org.apache.wicket.application.IClassResolver;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.IMarkupFragment;
 import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 import org.apache.wicket.markup.html.link.DisabledAttributeLinkBehavior;
-import org.apache.wicket.markup.html.link.ExternalLink;
 import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -517,41 +517,6 @@ public final class AutoLinkResolver implements IComponentResolver
 	}
 
 	/**
-	 * Autolink components delegate component resolution to their parent components. Reason:
-	 * autolink tags don't have wicket:id and users wouldn't know where to add the component to.
-	 * 
-	 * @author Juergen Donnerstag
-	 */
-	private final static class AutolinkExternalLink extends ExternalLink
-		implements
-			IComponentResolver
-	{
-		private static final long serialVersionUID = 1L;
-
-		/**
-		 * Construct
-		 * 
-		 * @param id
-		 * @param href
-		 */
-		public AutolinkExternalLink(final String id, final String href)
-		{
-			super(id, href);
-		}
-
-		/**
-		 * @see org.apache.wicket.markup.resolver.IComponentResolver#resolve(org.apache.wicket.MarkupContainer,
-		 *      org.apache.wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag)
-		 */
-		@Override
-		public Component resolve(MarkupContainer container, MarkupStream markupStream,
-			ComponentTag tag)
-		{
-			return getParent().get(tag.getId());
-		}
-	}
-
-	/**
 	 * Resolver that returns the proper attribute value from a component tag reflecting a URL
 	 * reference such as src or href.
 	 */
@@ -900,7 +865,7 @@ public final class AutoLinkResolver implements IComponentResolver
 			// resolving didn't have the desired result or there was no delegate
 			// found; fallback on the default resolving which is a simple
 			// component that leaves the tag unchanged
-			autoComponent = new WebMarkupContainer(componentId);
+			autoComponent = new TransparentWebMarkupContainer(componentId);
 		}
 
 		return autoComponent;

http://git-wip-us.apache.org/repos/asf/wicket/blob/86b3abad/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.html
new file mode 100644
index 0000000..560f750
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.html
@@ -0,0 +1,5 @@
+<html xmlns:wicket>
+<body>
+    <a href="/foo.html"><span wicket:id="label"></span></a>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/86b3abad/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.java
new file mode 100644
index 0000000..322cf19
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkPage_6.java
@@ -0,0 +1,32 @@
+/*
+ * 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.markup.html.link;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+public class AutolinkPage_6 extends WebPage {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 7778422734672899670L;
+	
+	public AutolinkPage_6() {
+		add(new Label("label","label"));
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/86b3abad/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkTest.java
index 31512ed..14321f9 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/link/AutolinkTest.java
@@ -75,4 +75,11 @@ public class AutolinkTest extends WicketTestCase
 		tester.getApplication().getMarkupSettings().setAutomaticLinking(true);
 		executeTest(AutolinkPage_5.class, "AutolinkPageExpectedResult_5.html");
 	}
+	
+	@Test
+	public void componentInsideAutolink() throws Exception 
+	{
+		tester.getApplication().getMarkupSettings().setAutomaticLinking(true);
+		tester.startPage(AutolinkPage_6.class);
+	}
 }