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 2015/05/18 13:40:38 UTC

wicket git commit: WICKET-5908 A new HtmlHeaderContainer is added each time a page instance is rendered

Repository: wicket
Updated Branches:
  refs/heads/master 6dfe99f17 -> 0a1024b1a


WICKET-5908 A new HtmlHeaderContainer is added each time a page instance is rendered


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

Branch: refs/heads/master
Commit: 0a1024b1ac8ae220d19ced0ee255a766f2eae5f4
Parents: 6dfe99f
Author: Andrea Del Bene <“adelbene@apache.org”>
Authored: Mon May 18 13:40:19 2015 +0200
Committer: Andrea Del Bene <“adelbene@apache.org”>
Committed: Mon May 18 13:40:19 2015 +0200

----------------------------------------------------------------------
 .../parser/filter/HtmlHeaderSectionHandler.java | 147 +++++++++++--------
 .../markup/resolver/HtmlHeaderResolver.java     |   7 +-
 .../html/autocomponent/AutoComponentsPage.html  |  15 ++
 .../html/autocomponent/AutoComponentsPage.java  |  36 +++++
 .../AutocomponetsGenerationTest.java            |  49 +++++++
 .../CheckGroupDisabledTestPage_expected.html    |   4 +-
 .../html/form/CheckGroupTestPage1_expected.html |   4 +-
 .../html/form/CheckGroupTestPage2_expected.html |   4 +-
 .../html/form/CheckGroupTestPage3_expected.html |   4 +-
 .../html/form/CheckGroupTestPage4_expected.html |   4 +-
 .../RadioGroupDisabledTestPage_expected.html    |   4 +-
 .../html/form/RadioGroupTestPage1_expected.html |   4 +-
 .../html/form/RadioGroupTestPage3_expected.html |   4 +-
 .../markup/parser/filter/DoubleHeadTagPage.html |  13 ++
 .../markup/parser/filter/DoubleHeadTagPage.java |  24 +++
 .../markup/parser/filter/HeaderSectionTest.java |  10 ++
 16 files changed, 255 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
index 6d08c95..da416eb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
@@ -55,12 +55,15 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
 	/** The automatically assigned wicket:id to &gt;head&lt; tag */
 	public static final String HEADER_ID = "_header_";
 
+	public static final String HEADER_ID_ITEM = "_header_item_";
+
 	/** True if &lt;head&gt; has been found already */
 	private boolean foundHead = false;
 
 	/** True if &lt;/head&gt; has been found already */
 	private boolean foundClosingHead = false;
-
+	
+	/** True if &lt;/wicket:header-items&gt; has been found already */
 	private boolean foundHeaderItemsTag = false;
 
 	/** True if all the rest of the markup file can be ignored */
@@ -95,35 +98,7 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
 		{
 			if (tag.getNamespace() == null)
 			{
-				// we found <head>
-				if (tag.isOpen())
-				{
-					foundHead = true;
-
-					if (tag.getId() == null)
-					{
-						tag.setId(HEADER_ID);
-						tag.setAutoComponentTag(true);
-						tag.setModified(true);
-					}
-				}
-				else if (tag.isClose())
-				{
-					if (foundHeaderItemsTag)
-					{
-						// revert the settings from above
-						ComponentTag headOpenTag = tag.getOpenTag();
-						// change the id because it is special. See HtmlHeaderResolver
-						headOpenTag.setId(HEADER_ID + "-Ignored");
-						headOpenTag.setAutoComponentTag(false);
-						headOpenTag.setModified(false);
-						headOpenTag.setFlag(ComponentTag.RENDER_RAW, true);
-					}
-
-					foundClosingHead = true;
-				}
-
-				return tag;
+				handleHeadTag(tag);
 			}
 			else
 			{
@@ -135,49 +110,105 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
 		else if (HtmlHeaderResolver.HEADER_ITEMS.equalsIgnoreCase(tag.getName()) &&
 				tag.getNamespace().equalsIgnoreCase(getWicketNamespace()))
 		{
-			if (foundHeaderItemsTag)
-			{
-				throw new MarkupException(new MarkupStream(markup),
-						"More than one <wicket:header-items/> detected in the <head> element. Only one is allowed.");
-			}
-			else if (foundClosingHead)
-			{
-				throw new MarkupException(new MarkupStream(markup),
-						"Detected <wicket:header-items/> after the closing </head> element.");
-			}
+			handleHeaderItemsTag(tag);
+		}
+		else if (BODY.equalsIgnoreCase(tag.getName()) && (tag.getNamespace() == null))
+		{
+			handleBodyTag();
+		}
 
-			foundHeaderItemsTag = true;
-			tag.setId(HEADER_ID);
-			tag.setAutoComponentTag(true);
-			tag.setModified(true);
+		return tag;
+	}
 
-			return tag;
+	/**
+	 * Handle tag &lt;body&gt;
+	 */
+	private void handleBodyTag()
+	{
+		// WICKET-4511: We found <body> inside <head> tag. Markup is not valid!
+		if (foundHead && !foundClosingHead)
+		{
+			throw new MarkupException(new MarkupStream(markup),
+				"Invalid page markup. Tag <BODY> found inside <HEAD>");
 		}
-		else if (BODY.equalsIgnoreCase(tag.getName()) && (tag.getNamespace() == null))
+
+		// We found <body>
+		if (foundHead == false)
 		{
-			// WICKET-4511: We found <body> inside <head> tag. Markup is not valid!
-			if (foundHead && !foundClosingHead)
+			insertHeadTag();
+		}
+
+		// <head> must always be before <body>
+		ignoreTheRest = true;
+	}
+
+	/**
+	 * Handle tag &lt;wicket:header-items&gt;
+	 * 
+	 * @param tag
+	 */
+	private void handleHeaderItemsTag(ComponentTag tag)
+	{
+		if (foundHeaderItemsTag)
+		{
+			throw new MarkupException(new MarkupStream(markup),
+					"More than one <wicket:header-items/> detected in the <head> element. Only one is allowed.");
+		}
+		else if (foundClosingHead)
+		{
+			throw new MarkupException(new MarkupStream(markup),
+					"Detected <wicket:header-items/> after the closing </head> element.");
+		}
+
+		foundHeaderItemsTag = true;
+		tag.setId(HEADER_ID);
+		tag.setAutoComponentTag(true);
+		tag.setModified(true);
+	}
+
+	/**
+	 * Handle tag &lt;head&gt;
+	 * @param tag
+	 */
+	private void handleHeadTag(ComponentTag tag)
+	{
+		// we found <head>
+		if (tag.isOpen())
+		{
+			if(foundHead)
 			{
 				throw new MarkupException(new MarkupStream(markup),
-					"Invalid page markup. Tag <BODY> found inside <HEAD>");
+					"Tag <head> is not allowed at this position (do you have multiple <head> tags in your markup?).");
 			}
+			
+			foundHead = true;
 
-			// We found <body>
-			if (foundHead == false)
+			if (tag.getId() == null)
 			{
-				insertHeadTag();
+				tag.setId(HEADER_ID);
+				tag.setAutoComponentTag(true);
+				tag.setModified(true);
 			}
-
-			// <head> must always be before <body>
-			ignoreTheRest = true;
-			return tag;
 		}
+		else if (tag.isClose())
+		{
+			if (foundHeaderItemsTag)
+			{
+				// revert the settings from above
+				ComponentTag headOpenTag = tag.getOpenTag();
+				// change the id because it is special. See HtmlHeaderResolver
+				headOpenTag.setId(HEADER_ID + "-Ignored");
+				headOpenTag.setAutoComponentTag(false);
+				headOpenTag.setModified(false);
+				headOpenTag.setFlag(ComponentTag.RENDER_RAW, true);
+			}
 
-		return tag;
+			foundClosingHead = true;
+		}
 	}
 
 	/**
-	 * Insert <head> open and close tag (with empty body) to the current position.
+	 * Insert &lt;head&gt; open and close tag (with empty body) to the current position.
 	 */
 	private void insertHeadTag()
 	{

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/main/java/org/apache/wicket/markup/resolver/HtmlHeaderResolver.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/HtmlHeaderResolver.java b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/HtmlHeaderResolver.java
index 0838594..2450704 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/HtmlHeaderResolver.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/HtmlHeaderResolver.java
@@ -66,8 +66,7 @@ public class HtmlHeaderResolver implements IComponentResolver
 		{
 			// Create a special header component which will gather additional
 			// input the <head> from 'contributors'.
-			return newHtmlHeaderContainer(HtmlHeaderSectionHandler.HEADER_ID +
-				page.getAutoIndex(), tag);
+			return newHtmlHeaderContainer(tag.getId(), tag);
 		}
 		else if ((tag instanceof WicketTag) && ((WicketTag)tag).isHeadTag())
 		{
@@ -100,8 +99,7 @@ public class HtmlHeaderResolver implements IComponentResolver
 				{
 					// Create a special header component which will gather
 					// additional input the <head> from 'contributors'.
-					header = newHtmlHeaderContainer(HtmlHeaderSectionHandler.HEADER_ID +
-						page.getAutoIndex(), tag);
+					header = newHtmlHeaderContainer(tag.getId(), tag);
 					header.add(new WicketHeadContainer());
 					return header;
 				}
@@ -174,6 +172,7 @@ public class HtmlHeaderResolver implements IComponentResolver
 		{
 			htmlHeaderContainer = newHtmlHeaderContainer(id);
 		}
+		
 		return htmlHeaderContainer;
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.html
new file mode 100644
index 0000000..25d58e5
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta charset="UTF-8">
+		<title>Insert title here</title>
+		<link rel="stylesheet" type="text/css" href="css/style.css"/>
+	</head>
+<body>
+
+	<wicket:enclosure>
+		<span wicket:id="hello">Hello!</span>
+	</wicket:enclosure>
+	<img alt="myPicture" src="imgs/mylogo.png">
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.java
new file mode 100644
index 0000000..e9f0786
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsPage.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.autocomponent;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Page containing only autocomponents (header, enclosures, img tags, etc...)
+ * 
+ * @author andrea del bene
+ *
+ */
+public class AutoComponentsPage extends WebPage
+{
+	@Override
+	protected void onInitialize()
+	{
+		super.onInitialize();
+		add(new Label("hello"));
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
new file mode 100644
index 0000000..cee6b23
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.autocomponent;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.IMarkupCache;
+import org.junit.Test;
+
+/*
+ * Test case for https://issues.apache.org/jira/browse/WICKET-5904
+ * and for https://issues.apache.org/jira/browse/WICKET-5908
+ */
+public class AutocomponetsGenerationTest extends WicketTestCase
+{
+
+	@Test
+	public void autocomponetsNumberDoesntChange()
+	{
+		AutoComponentsPage autoComponentsPage = new AutoComponentsPage();
+		tester.startPage(autoComponentsPage);
+		
+		int childrenNumber = tester.getLastRenderedPage().size();
+		
+		//clean markup cache and render the same page instance again
+		IMarkupCache markupCache = tester.getApplication().getMarkupSettings().getMarkupFactory().getMarkupCache();
+		
+		markupCache.clear();
+		tester.startPage(autoComponentsPage);
+		
+		//the number of child components must not have been changed
+		assertEquals(childrenNumber, tester.getLastRenderedPage().size());
+		
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
index 86416ac..dfba8d0 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupDisabledTestPage_expected.html
@@ -4,9 +4,9 @@
     <!--  In addition test that chars are not converted from upper to lower and vice versa -->
 	<FORM wicket:id="form" id="form1" method="post" action="./org.apache.wicket.markup.html.form.CheckGroupDisabledTestPage?0-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
 		<span wicket:id="group">
-			<input type="checkbox" wicket:id="check1" id="check12" name="group" value="check1" checked="checked" disabled="disabled">check1</input>
+			<input type="checkbox" wicket:id="check1" id="check12" name="group" value="check0" checked="checked" disabled="disabled">check1</input>
 			<span wicket:id="container">
-				<input type="checkbox" wicket:id="check2" id="check23" name="group" value="check2" checked="checked" disabled="disabled">check2</input>
+				<input type="checkbox" wicket:id="check2" id="check23" name="group" value="check1" checked="checked" disabled="disabled">check2</input>
 			</span>
 		</span>
 	</FORM>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage1_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage1_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage1_expected.html
index faf38b5..8f23b9b 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage1_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage1_expected.html
@@ -4,9 +4,9 @@
     <!--  In addition test that chars are not converted from upper to lower and vice versa -->
 	<FORM wicket:id="form" id="form1" method="post" action="./org.apache.wicket.markup.html.form.CheckGroupTestPage1?0-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
 		
-			<input type="checkbox" wicket:id="check1" id="check12" name="group" value="check1">check1</input>
+			<input type="checkbox" wicket:id="check1" id="check12" name="group" value="check0">check1</input>
 			<span wicket:id="container">
-				<input type="checkbox" wicket:id="check2" id="check23" name="group" value="check2">check2</input>
+				<input type="checkbox" wicket:id="check2" id="check23" name="group" value="check1">check2</input>
 			</span>
 		
 	</FORM>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage2_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage2_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage2_expected.html
index 73e0397..c35c499 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage2_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage2_expected.html
@@ -3,9 +3,9 @@
 <body>
 	<form wicket:id="form" id="form4" method="post" action="./org.apache.wicket.markup.html.form.CheckGroupTestPage2?1-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form4_hf_0" id="form4_hf_0" /></div>
 		
-			<input type="checkbox" wicket:id="check1" id="check15" name="group" value="check1" checked="checked">check1</input>
+			<input type="checkbox" wicket:id="check1" id="check15" name="group" value="check0" checked="checked">check1</input>
 			<span wicket:id="container">
-				<input type="checkbox" wicket:id="check2" id="check26" name="group" value="check2">check2</input>
+				<input type="checkbox" wicket:id="check2" id="check26" name="group" value="check1">check2</input>
 			</span>
 		
 	</form>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage3_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage3_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage3_expected.html
index ead5ca4..0af457e 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage3_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage3_expected.html
@@ -3,9 +3,9 @@
 <body>
 	<form wicket:id="form" id="form7" method="post" action="./org.apache.wicket.markup.html.form.CheckGroupTestPage3?2-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form7_hf_0" id="form7_hf_0" /></div>
 		
-			<input type="checkbox" wicket:id="check1" id="check18" name="group" value="check1">check1</input>
+			<input type="checkbox" wicket:id="check1" id="check18" name="group" value="check0">check1</input>
 			<span wicket:id="container">
-				<input type="checkbox" wicket:id="check2" id="check29" name="group" value="check2" checked="checked">check2</input>
+				<input type="checkbox" wicket:id="check2" id="check29" name="group" value="check1" checked="checked">check2</input>
 			</span>
 		
 	</form>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage4_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage4_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage4_expected.html
index aa677ec..9a76d22 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage4_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTestPage4_expected.html
@@ -3,9 +3,9 @@
 <body>
 	<form wicket:id="form" id="forma" method="post" action="./org.apache.wicket.markup.html.form.CheckGroupTestPage4?3-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="forma_hf_0" id="forma_hf_0" /></div>
 		
-			<input type="checkbox" wicket:id="check1" id="check1b" name="group" value="check1" checked="checked">check1</input>
+			<input type="checkbox" wicket:id="check1" id="check1b" name="group" value="check0" checked="checked">check1</input>
 			<span wicket:id="container">
-				<input type="checkbox" wicket:id="check2" id="check2c" name="group" value="check2" checked="checked">check2</input>
+				<input type="checkbox" wicket:id="check2" id="check2c" name="group" value="check1" checked="checked">check2</input>
 			</span>
 		
 	</form>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
index 2d42066..ad4f11a 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupDisabledTestPage_expected.html
@@ -3,9 +3,9 @@
 <body>
 	<form wicket:id="form" id="form1" method="post" action="./org.apache.wicket.markup.html.form.RadioGroupDisabledTestPage?0-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
 		<span wicket:id="group">
-			<input type="radio" wicket:id="radio1" id="radio12" name="group" value="radio1" disabled="disabled">radio1</input>
+			<input type="radio" wicket:id="radio1" id="radio12" name="group" value="radio0" disabled="disabled">radio1</input>
 			<span wicket:id="container">
-				<input type="radio" wicket:id="radio2" id="radio23" name="group" value="radio2" checked="checked" disabled="disabled">radio2</input>
+				<input type="radio" wicket:id="radio2" id="radio23" name="group" value="radio1" checked="checked" disabled="disabled">radio2</input>
 			</span>
 		</span>
 	</form>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage1_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage1_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage1_expected.html
index d6dac16..5d518b7 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage1_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage1_expected.html
@@ -3,9 +3,9 @@
 <body>
 	<form wicket:id="form" id="form1" method="post" action="./org.apache.wicket.markup.html.form.RadioGroupTestPage1?0-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
 		
-			<input type="radio" wicket:id="radio1" id="radio12" name="group" value="radio1">radio1</input>
+			<input type="radio" wicket:id="radio1" id="radio12" name="group" value="radio0">radio1</input>
 			<span wicket:id="container">
-				<input type="radio" wicket:id="radio2" id="radio23" name="group" value="radio2" checked="checked">radio2</input>
+				<input type="radio" wicket:id="radio2" id="radio23" name="group" value="radio1" checked="checked">radio2</input>
 			</span>
 		
 	</form>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage3_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage3_expected.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage3_expected.html
index 891d130..30d2934 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage3_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/RadioGroupTestPage3_expected.html
@@ -2,8 +2,8 @@
 <body>
 <form wicket:id="form" id="form1" method="post" action="./org.apache.wicket.markup.html.form.RadioGroupTestPage3?0-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
 	
-		<input wicket:id="check1" type="radio" id="check12" name="radio" value="radio1" checked="checked">Yes
-		<input wicket:id="check2" type="radio" id="check23" name="radio" value="radio2" checked="checked">No
+		<input wicket:id="check1" type="radio" id="check12" name="radio" value="radio0" checked="checked">Yes
+		<input wicket:id="check2" type="radio" id="check23" name="radio" value="radio1" checked="checked">No
 	
 </form>
 </body>

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.html
new file mode 100644
index 0000000..458024c
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta charset="UTF-8">
+		<title>Insert title here</title>
+	</head>
+	<head>
+		<title>Additional head tag</title>
+	</head>
+<body>
+
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.java
new file mode 100644
index 0000000..5f6dfac
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/DoubleHeadTagPage.java
@@ -0,0 +1,24 @@
+/*
+ * 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.parser.filter;
+
+import org.apache.wicket.markup.html.WebPage;
+
+public class DoubleHeadTagPage extends WebPage
+{
+
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a1024b1/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/HeaderSectionTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/HeaderSectionTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/HeaderSectionTest.java
index ae8403d..0908f0c 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/HeaderSectionTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/parser/filter/HeaderSectionTest.java
@@ -18,6 +18,7 @@ package org.apache.wicket.markup.parser.filter;
 
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.MarkupException;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -221,4 +222,13 @@ public class HeaderSectionTest extends WicketTestCase
 	{
 		executeTest(HeaderSectionPage_20.class, "HeaderSectionPageExpectedResult_20.html");
 	}
+	
+	/**
+	 * https://issues.apache.org/jira/browse/WICKET-5908
+	 */
+	@Test(expected = MarkupException.class)
+	public void doubleHeadTagPage()
+	{
+		tester.startPage(DoubleHeadTagPage.class);
+	}
 }