Repository: wicket
Updated Branches:
  refs/heads/wicket-7.x a3f6677b5 -> 35aacc4ef


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/35aacc4e
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/35aacc4e
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/35aacc4e

Branch: refs/heads/wicket-7.x
Commit: 35aacc4ef10d473c97155470cd4d55aa19b9f4c2
Parents: a3f6677
Author: Andrea Del Bene <[email protected]>
Authored: Thu May 25 22:27:12 2017 +0200
Committer: Andrea Del Bene <[email protected]>
Committed: Fri May 26 11:54:59 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/35aacc4e/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 ebc09b3..86aef0f 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.
         */
@@ -903,7 +868,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/35aacc4e/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/35aacc4e/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/35aacc4e/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);
+       }
 }

Reply via email to