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 2016/10/26 16:20:09 UTC
wicket git commit: WICKET-6256 8.0.0-M1
MarkupNotFoundException
Repository: wicket
Updated Branches:
refs/heads/master 12d096ccc -> ebc503324
WICKET-6256 8.0.0-M1 <wicket:link> MarkupNotFoundException
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/ebc50332
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/ebc50332
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/ebc50332
Branch: refs/heads/master
Commit: ebc503324c8eabdf57d70c9294cf03d0f559564a
Parents: 12d096c
Author: Andrea Del Bene <ad...@apache.org>
Authored: Wed Oct 26 18:19:33 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Wed Oct 26 18:19:33 2016 +0200
----------------------------------------------------------------------
.../markup/parser/AbstractMarkupFilter.java | 2 +-
.../markup/parser/filter/RootMarkupFilter.java | 11 ++++
.../AutocomponetsGenerationTest.java | 15 +++++
.../markup/html/autocomponent/UniqueIdTest.html | 11 ++++
.../markup/html/autocomponent/UniqueIdTest.java | 62 ++++++++++++++++++++
5 files changed, 100 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/ebc50332/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
index f37b94d..981614c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/AbstractMarkupFilter.java
@@ -54,7 +54,7 @@ public abstract class AbstractMarkupFilter implements IMarkupFilter
* meaning that each container has its own counter.
* The counters are used by {@link #getRequestUniqueId()} to get unique ids for markup tags.
* **/
- private final static MetaDataKey<Map<String, AtomicInteger>> REQUEST_COUNTER_KEY = new MetaDataKey<Map<String, AtomicInteger>>()
+ protected final static MetaDataKey<Map<String, AtomicInteger>> REQUEST_COUNTER_KEY = new MetaDataKey<Map<String, AtomicInteger>>()
{
private static final long serialVersionUID = 1L;
};
http://git-wip-us.apache.org/repos/asf/wicket/blob/ebc50332/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RootMarkupFilter.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RootMarkupFilter.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RootMarkupFilter.java
index 1c37fba..63bbb4f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RootMarkupFilter.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RootMarkupFilter.java
@@ -17,6 +17,8 @@
package org.apache.wicket.markup.parser.filter;
import java.text.ParseException;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.HtmlSpecialTag;
@@ -27,6 +29,7 @@ import org.apache.wicket.markup.parser.AbstractMarkupFilter;
import org.apache.wicket.markup.parser.IMarkupFilter;
import org.apache.wicket.markup.parser.IXmlPullParser;
import org.apache.wicket.markup.parser.IXmlPullParser.HttpTagType;
+import org.apache.wicket.request.cycle.RequestCycle;
/**
@@ -109,6 +112,14 @@ public final class RootMarkupFilter extends AbstractMarkupFilter
@Override
public final void postProcess(Markup markup)
{
+ //once we have done filtering, we reset markup counters for ids
+ RequestCycle requestCycle = RequestCycle.get();
+ Map<String, AtomicInteger> markupUniqueCounters = requestCycle.getMetaData(REQUEST_COUNTER_KEY);
+
+ if (markupUniqueCounters != null)
+ {
+ markupUniqueCounters.clear();
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/wicket/blob/ebc50332/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
index 7c0f45d..d5dbff6 100644
--- 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
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.markup.html.autocomponent;
+import org.apache.wicket.Page;
import org.apache.wicket.core.util.string.ComponentRenderer;
import org.apache.wicket.markup.IMarkupCache;
import org.apache.wicket.util.tester.WicketTestCase;
@@ -65,4 +66,18 @@ public class AutocomponetsGenerationTest extends WicketTestCase
//the number of child components must not have been changed
assertEquals(2, border.size());
}
+
+ /*
+ * Test for https://issues.apache.org/jira/browse/WICKET-6256
+ */
+ @Test
+ public void autoComponentsIdsGeneration() throws Exception
+ {
+ Page page = new UniqueIdTest();
+
+ tester.startPage(page);
+
+ //render page again. Autocomponents must have the same id
+ tester.startPage(page);
+ }
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/ebc50332/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.html
new file mode 100644
index 0000000..6c1cd85
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+my body
+<div wicket:id="panel"></div>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/ebc50332/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.java
new file mode 100644
index 0000000..43782e9
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/UniqueIdTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.MarkupContainer;
+import org.apache.wicket.markup.IMarkupCacheKeyProvider;
+import org.apache.wicket.markup.IMarkupResourceStreamProvider;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.util.resource.IResourceStream;
+import org.apache.wicket.util.resource.StringResourceStream;
+
+public class UniqueIdTest extends WebPage {
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+ add(new CacheKeyNullPanel("panel"));
+
+ }
+
+
+ class CacheKeyNullPanel extends Panel implements
+ IMarkupResourceStreamProvider,
+ IMarkupCacheKeyProvider
+ {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -437057755276096255L;
+
+ public CacheKeyNullPanel(String id) {
+ super(id);
+ }
+
+ @Override
+ public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
+ return new StringResourceStream("<wicket:panel><img src='mypic.jpg'></wicket:panel>");
+ }
+
+ @Override
+ public String getCacheKey(MarkupContainer container, Class<?> containerClass) {
+ return null;
+ }
+
+ }
+}