You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/04/27 12:37:46 UTC

git commit: WICKET-4520 Inline enclosure doesn't work if wicket:message attribute is used on the same tag

Updated Branches:
  refs/heads/wicket-1.5.x fbf0ead45 -> fad724f37


WICKET-4520 Inline enclosure doesn't work if wicket:message attribute is used on the same tag


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

Branch: refs/heads/wicket-1.5.x
Commit: fad724f377e501a5d9a5e547d579b4b5f4e4f6a4
Parents: fbf0ead
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Apr 27 13:36:43 2012 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Apr 27 13:36:43 2012 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/wicket/Application.java   |    2 +-
 .../org/apache/wicket/markup/MarkupParser.java     |    3 +-
 .../parser/filter/InlineEnclosureHandler.java      |    5 +-
 .../parser/filter/WicketMessageTagHandler.java     |    4 +-
 .../markup/html/internal/InlineEnclosureTest.java  |   28 +++++++++++
 .../InlineEnclosureWithWicketMessagePage.html      |   30 ++++++++++++
 .../InlineEnclosureWithWicketMessagePage.java      |   36 +++++++++++++++
 ...InlineEnclosureWithWicketMessagePage.properties |    1 +
 ...reWithWicketMessagePage_invisible_expected.html |   26 +++++++++++
 ...sureWithWicketMessagePage_visible_expected.html |   30 ++++++++++++
 10 files changed, 157 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/main/java/org/apache/wicket/Application.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java b/wicket-core/src/main/java/org/apache/wicket/Application.java
index 9b5bc84..7b4147b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -680,11 +680,11 @@ public abstract class Application implements UnboundListener, IEventSink
 		pageSettings.addComponentResolver(new HtmlHeaderResolver());
 		pageSettings.addComponentResolver(new WicketLinkTagHandler());
 		pageSettings.addComponentResolver(new WicketMessageResolver());
-		pageSettings.addComponentResolver(new WicketMessageTagHandler());
 		pageSettings.addComponentResolver(new FragmentResolver());
 		pageSettings.addComponentResolver(new RelativePathPrefixHandler());
 		pageSettings.addComponentResolver(new EnclosureHandler());
 		pageSettings.addComponentResolver(new InlineEnclosureHandler());
+		pageSettings.addComponentResolver(new WicketMessageTagHandler());
 		pageSettings.addComponentResolver(new WicketContainerResolver());
 
 		// Install button image resource factory

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/main/java/org/apache/wicket/markup/MarkupParser.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/MarkupParser.java b/wicket-core/src/main/java/org/apache/wicket/markup/MarkupParser.java
index 7308313..55a92c3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/MarkupParser.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/MarkupParser.java
@@ -150,6 +150,7 @@ public class MarkupParser extends AbstractMarkupParser
 		filters.add(new WicketLinkTagHandler());
 		filters.add(new AutoLabelTagHandler());
 		filters.add(new WicketNamespaceHandler(markupResourceStream));
+		filters.add(new WicketMessageTagHandler(markupResourceStream));
 
 		// Provided the wicket component requesting the markup is known ...
 		if ((markupResourceStream != null) && (markupResourceStream.getResource() != null))
@@ -157,8 +158,6 @@ public class MarkupParser extends AbstractMarkupParser
 			final ContainerInfo containerInfo = markupResourceStream.getContainerInfo();
 			if (containerInfo != null)
 			{
-				filters.add(new WicketMessageTagHandler(markupResourceStream));
-
 				// Pages require additional handlers
 				if (Page.class.isAssignableFrom(containerInfo.getContainerClass()))
 				{

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
index 8bab4f9..2ba54bb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
@@ -43,7 +43,6 @@ import org.apache.wicket.util.string.Strings;
  * enclosure is identified by the 'child' attribute value which must be equal to the relative child
  * id path.
  * 
- * @see EnclosureResolver
  * @see InlineEnclosure
  * 
  * @author Joonas Hamalainen
@@ -96,7 +95,7 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
 							tag.toString(), tag.getPos());
 				}
 
-				// if it doesn't have a wicket-id already, than assign one now.
+				// if it doesn't have a wicket-id already, then assign one now.
 				if (Strings.isEmpty(tag.getId()))
 				{
 					if (Strings.isEmpty(htmlId))
@@ -129,7 +128,7 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
 		// Are we within an enclosure?
 		else if ((enclosures != null) && (enclosures.size() > 0))
 		{
-			// In case the enclosure tag did not provide a child component id, than assign the
+			// In case the enclosure tag did not provide a child component id, then assign the
 			// first ComponentTag's id found as the controlling child to the enclosure.
 			if (tag.isOpen() && (tag.getId() != null) && !(tag instanceof WicketTag) &&
 				!tag.isAutoComponentTag())

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
index 3f79e24..6df1ca2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
@@ -91,7 +91,7 @@ public final class WicketMessageTagHandler extends AbstractMarkupFilter
 		final String wicketMessageAttribute = tag.getAttributes().getString(
 			getWicketMessageAttrName());
 
-		if ((wicketMessageAttribute != null) && (wicketMessageAttribute.trim().length() > 0))
+		if (Strings.isEmpty(wicketMessageAttribute) == false)
 		{
 			// check if this tag is raw markup
 			if (tag.getId() == null)
@@ -177,7 +177,7 @@ public final class WicketMessageTagHandler extends AbstractMarkupFilter
 		// localize any raw markup that has wicket:message attrs
 		if ((tag != null) && (tag.getId().startsWith(WICKET_MESSAGE_CONTAINER_ID)))
 		{
-			Component wc = null;
+			Component wc;
 			int autoIndex = container.getPage().getAutoIndex();
 			String id = WICKET_MESSAGE_CONTAINER_ID + autoIndex;
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureTest.java
index 879e552..f085672 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureTest.java
@@ -56,6 +56,34 @@ public class InlineEnclosureTest extends WicketTestCase
 		executeTest(InlineEnclosurePanelPage.class, "InlineEnclosurePanelPageExpectedResult.html");
 	}
 
+	/**
+	 * https://issues.apache.org/jira/browse/WICKET-4520
+	 *
+	 * Tests that wicket:enclosure and wicket:message attributes can co-exist
+	 *
+	 * @throws Exception
+	 */
+	@Test
+	public void inlineEnclosureWithWicketMessageVisible() throws Exception
+	{
+		executeTest(new InlineEnclosureWithWicketMessagePage(true),
+				"InlineEnclosureWithWicketMessagePage_visible_expected.html");
+	}
+
+	/**
+	 *
+	 * https://issues.apache.org/jira/browse/WICKET-4520
+	 *
+	 * Tests that wicket:enclosure and wicket:message attributes can co-exist
+	 * 
+	 * @throws Exception
+	 */
+	@Test
+	public void inlineEnclosureWithWicketMessageInvisible() throws Exception
+	{
+		executeTest(new InlineEnclosureWithWicketMessagePage(false),
+				"InlineEnclosureWithWicketMessagePage_invisible_expected.html");
+	}
 
 	@Override
 	protected WebApplication newApplication()

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.html
new file mode 100644
index 0000000..cb57792
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.html
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+   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.
+-->
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<head>
+	<title>Wicket 4520</title>
+</head>
+<body>
+	<div wicket:enclosure="child" wicket:message="title:titleAttr">
+		<div>Inner div
+			<span wicket:id="child">Blah</span>
+		</div>
+	</div>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.java
new file mode 100644
index 0000000..aebf680
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.java
@@ -0,0 +1,36 @@
+/*
+ * 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.internal;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Test page for InlineEnclosureTest.
+ * Tests methods:
+ * 1) inlineEnclosureWithWicketMessageVisible()
+ * 2) inlineEnclosureWithWicketMessageInvisible
+ *
+ * @since 1.5.6
+ */
+public class InlineEnclosureWithWicketMessagePage extends WebPage
+{
+	public InlineEnclosureWithWicketMessagePage(boolean childVisible)
+	{
+		add(new Label("child", "A Label").setVisible(childVisible));
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.properties
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.properties b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.properties
new file mode 100644
index 0000000..1e12905
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage.properties
@@ -0,0 +1 @@
+titleAttr=Some title
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_invisible_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_invisible_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_invisible_expected.html
new file mode 100644
index 0000000..6252a42
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_invisible_expected.html
@@ -0,0 +1,26 @@
+
+<!--
+   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.
+-->
+<!DOCTYPE html>
+<html>
+<head>
+	<title>Wicket 4520</title>
+</head>
+<body>
+	<div id="_message_attr_" style="display:none"></div>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/fad724f3/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_visible_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_visible_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_visible_expected.html
new file mode 100644
index 0000000..62d9d09
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosureWithWicketMessagePage_visible_expected.html
@@ -0,0 +1,30 @@
+
+<!--
+   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.
+-->
+<!DOCTYPE html>
+<html>
+<head>
+	<title>Wicket 4520</title>
+</head>
+<body>
+	<div id="_message_attr_" title="Some title">
+		<div>Inner div
+			<span>A Label</span>
+		</div>
+	</div>
+</body>
+</html>
\ No newline at end of file