You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by cm...@apache.org on 2012/07/27 18:16:58 UTC

[2/2] git commit: WICKET-4681 AutoLinkResolver now checks Panel's markup correctly too

WICKET-4681 AutoLinkResolver now checks Panel's markup correctly too


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

Branch: refs/heads/wicket-1.5.x
Commit: 9d4fa80eb3567ecb0c807794a3a783cf6b860e45
Parents: 70101b0
Author: Carl-Eric Menzel <cm...@wicketbuch.de>
Authored: Fri Jul 27 17:53:20 2012 +0200
Committer: Carl-Eric Menzel <cm...@wicketbuch.de>
Committed: Fri Jul 27 17:53:35 2012 +0200

----------------------------------------------------------------------
 .../wicket/markup/resolver/AutoLinkResolver.java   |    7 +-
 .../autolink/AutoLinkInPanelsTest$TestPage.html    |    6 +
 .../markup/html/autolink/AutoLinkInPanelsTest.java |   78 +++++++++++++++
 .../wicket/markup/html/autolink/sub/LogoPanel.html |   10 ++
 .../wicket/markup/html/autolink/sub/LogoPanel.java |   31 ++++++
 .../wicket/markup/html/autolink/sub/logo.png       |    1 +
 .../wicket/markup/html/autolink/sub/logo2.png      |    1 +
 7 files changed, 133 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/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 5b20adb..6f7ee71 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
@@ -98,7 +98,12 @@ public final class AutoLinkResolver implements IComponentResolver
 				// header has been added to (e.g. the Page). What we need
 				// however, is the component (e.g. a Panel) which
 				// contributed it.
-				MarkupStream markupStream = new MarkupStream(container.getMarkup());
+				IMarkupFragment markup = container.getAssociatedMarkup();
+				if (markup == null)
+				{
+					markup = container.getMarkup();
+				}
+				MarkupStream markupStream = new MarkupStream(markup);
 				Class<? extends Component> clazz = markupStream.getContainerClass();
 
 				// However if the markup stream is a merged markup stream (inheritance), than we

http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest$TestPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest$TestPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest$TestPage.html
new file mode 100644
index 0000000..a38c3de
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest$TestPage.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+    <body>
+        <div wicket:id="logo"></div>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest.java
new file mode 100644
index 0000000..ec62e47
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/AutoLinkInPanelsTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.autolink;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.autolink.sub.LogoPanel;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test for WICKET-4681
+ * 
+ * @author Carl-Eric Menzel
+ */
+public class AutoLinkInPanelsTest extends WicketTestCase
+{
+	public static class TestPage extends WebPage
+	{
+		public TestPage()
+		{
+			add(new LogoPanel("logo"));
+		}
+	}
+
+	@Before
+	public void setUp()
+	{
+		tester = new WicketTester(new WebApplication()
+		{
+
+			@Override
+			public Class<? extends Page> getHomePage()
+			{
+				return TestPage.class;
+			}
+
+			@Override
+			protected void init()
+			{
+				super.init();
+				getMarkupSettings().setAutomaticLinking(true);
+			}
+		});
+	}
+
+	@Test
+	public void imgTagWorksInPanelWithExtraContainer() throws Exception
+	{
+		tester.startPage(TestPage.class);
+		tester.dumpPage();
+		tester.assertContains("<img src=\"\\./wicket/resource/org.apache.wicket.markup.html.autolink.sub.LogoPanel/logo-ver-\\d+.png\"/>");
+	}
+
+	@Test
+	public void imgTagWorksInPanelWithoutExtraContainer() throws Exception
+	{
+		tester.startPage(TestPage.class);
+		tester.assertContains("<img src=\"\\./wicket/resource/org.apache.wicket.markup.html.autolink.sub.LogoPanel/logo2-ver-\\d+.png\"/>");
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.html
new file mode 100644
index 0000000..66c030a
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.html
@@ -0,0 +1,10 @@
+<wicket:panel>
+<div>
+<span wicket:id="label"></span>
+<span wicket:id="container">
+<img src="logo.png"/>
+<a href="HomePage.html"/>
+</span>
+<img src="logo2.png"/>
+</div>
+</wicket:panel>

http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.java
new file mode 100644
index 0000000..a416bfd
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/LogoPanel.java
@@ -0,0 +1,31 @@
+/*
+ * 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.autolink.sub;
+
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+public class LogoPanel extends Panel
+{
+	public LogoPanel(String id)
+	{
+		super(id);
+		add(new Label("label", "label"));
+		add(new WebMarkupContainer("container"));
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo.png
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo.png b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo.png
new file mode 100644
index 0000000..6e01540
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo.png
@@ -0,0 +1 @@
+...just a dummy resource...

http://git-wip-us.apache.org/repos/asf/wicket/blob/9d4fa80e/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo2.png
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo2.png b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo2.png
new file mode 100644
index 0000000..6e01540
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autolink/sub/logo2.png
@@ -0,0 +1 @@
+...just a dummy resource...