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 2013/05/28 22:16:09 UTC

git commit: WICKET-5209 NPE when using ComponentRenderer.renderComponent on a panel with

Updated Branches:
  refs/heads/wicket-6.x be0815a9f -> bbab63a53


WICKET-5209 NPE when using ComponentRenderer.renderComponent on a panel with <wicket:enclosure>


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

Branch: refs/heads/wicket-6.x
Commit: bbab63a5305550f6696fab696a5474ecbd1caac0
Parents: be0815a
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue May 28 23:13:15 2013 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue May 28 23:15:35 2013 +0300

----------------------------------------------------------------------
 .../wicket/core/util/string/ComponentRenderer.java |    1 +
 .../core/util/string/ComponentRendererTest.java    |   39 +++++++++++++++
 .../wicket/core/util/string/EnclosurePanel.html    |   22 ++++++++
 .../wicket/core/util/string/EnclosurePanel.java    |   35 +++++++++++++
 4 files changed, 97 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/bbab63a5/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
index 308b548..41704a6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
@@ -100,6 +100,7 @@ public class ComponentRenderer
 
 			RenderPage page = new RenderPage();
 			page.add(component);
+			page.internalInitialize();
 
 			component.render();
 		}

http://git-wip-us.apache.org/repos/asf/wicket/blob/bbab63a5/wicket-core/src/test/java/org/apache/wicket/core/util/string/ComponentRendererTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/core/util/string/ComponentRendererTest.java b/wicket-core/src/test/java/org/apache/wicket/core/util/string/ComponentRendererTest.java
new file mode 100644
index 0000000..80922f8
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/core/util/string/ComponentRendererTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.core.util.string;
+
+import org.apache.wicket.WicketTestCase;
+import org.junit.Test;
+
+/**
+ * Tests for ComponentRenderer
+ */
+public class ComponentRendererTest extends WicketTestCase
+{
+
+	/**
+	 * https://issues.apache.org/jira/browse/WICKET-5209
+	 *
+	 * Tests that the page and the components in it are initialized.
+	 * Enclosure won't know its child component without being initialized
+	 */
+	@Test
+	public void componentsAreInitialized()
+	{
+		ComponentRenderer.renderComponent(new EnclosurePanel(ComponentRenderer.COMP_ID));
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/bbab63a5/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.html b/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.html
new file mode 100644
index 0000000..2977d1b
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.html
@@ -0,0 +1,22 @@
+<!--
+    ====================================================================
+    Licensed 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/dtds.data/wicket-xhtml1.4-strict.dtd">
+	<wicket:panel>
+		<wicket:enclosure child="externalLink">
+			<a wicket:id="externalLink">Google</a>
+		</wicket:enclosure>
+	</wicket:panel>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/bbab63a5/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.java b/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.java
new file mode 100644
index 0000000..d204ed4
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/core/util/string/EnclosurePanel.java
@@ -0,0 +1,35 @@
+/*
+ * 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.core.util.string;
+
+import org.apache.wicket.markup.html.link.ExternalLink;
+import org.apache.wicket.markup.html.panel.Panel;
+
+class EnclosurePanel extends Panel
+{
+	
+	private static final long serialVersionUID = 1L;
+	
+	private static final String TEST_LINK = "http://google.com";
+
+	public EnclosurePanel(String id) {
+		super(id);
+		
+		ExternalLink externalLink = new ExternalLink("externalLink", TEST_LINK);
+		add(externalLink);
+	}
+}