You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2007/08/07 10:52:22 UTC

svn commit: r563430 - in /wicket/trunk/jdk-1.4/wicket/src: main/java/org/apache/wicket/ main/java/org/apache/wicket/markup/html/panel/ test/java/org/apache/wicket/markup/html/panel/

Author: jdonnerstag
Date: Tue Aug  7 01:52:21 2007
New Revision: 563430

URL: http://svn.apache.org/viewvc?view=rev&rev=563430
Log:
wicket-827: ajax refresh fails when fragment is included in the target

fixed and test case provided added

Added:
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html   (with props)
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.html   (with props)
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.java   (with props)
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.html   (with props)
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.java   (with props)
Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/PanelTest.java

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?view=diff&rev=563430&r1=563429&r2=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java Tue Aug  7 01:52:21 2007
@@ -349,7 +349,7 @@
 	 *            If true, throw an exception, if markup could not be found
 	 * @return A stream of MarkupElement elements
 	 */
-	public final MarkupStream getAssociatedMarkupStream(final boolean throwException)
+	public MarkupStream getAssociatedMarkupStream(final boolean throwException)
 	{
 		try
 		{
@@ -569,7 +569,7 @@
 			{
 				private static final long serialVersionUID = 1L;
 
-				final Object removedChildren = MarkupContainer.this.children;
+				final Object removedChildren = children;
 
 				public String toString()
 				{
@@ -579,7 +579,7 @@
 
 				public void undo()
 				{
-					MarkupContainer.this.children = removedChildren;
+					children = removedChildren;
 					int size = children_size();
 					for (int i = 0; i < size; i++)
 					{
@@ -603,7 +603,7 @@
 				child.setParent(null);
 			}
 
-			this.children = null;
+			children = null;
 		}
 	}
 
@@ -941,9 +941,9 @@
 	 */
 	private final void children_add(final Component child)
 	{
-		if (this.children == null)
+		if (children == null)
 		{
-			this.children = child;
+			children = child;
 		}
 		else
 		{
@@ -1056,7 +1056,7 @@
 			if (index == 0)
 			{
 				final Component removed = (Component)children;
-				this.children = null;
+				children = null;
 				return removed;
 			}
 			else
@@ -1072,11 +1072,11 @@
 			{
 				if (index == 0)
 				{
-					this.children = c[1];
+					children = c[1];
 				}
 				else if (index == 1)
 				{
-					this.children = c[0];
+					children = c[0];
 				}
 				else
 				{
@@ -1094,7 +1094,7 @@
 						newChildren[j++] = c[i];
 					}
 				}
-				this.children = newChildren;
+				children = newChildren;
 			}
 			return removed;
 		}
@@ -1228,7 +1228,7 @@
 				}
 
 				// 3rd try: Try application's component resolvers
-				final List componentResolvers = this.getApplication().getPageSettings()
+				final List componentResolvers = getApplication().getPageSettings()
 						.getComponentResolvers();
 				final Iterator iterator = componentResolvers.iterator();
 				while (iterator.hasNext())
@@ -1553,7 +1553,7 @@
 	/**
 	 * @return True if this markup container has associated markup
 	 */
-	final boolean hasAssociatedMarkup()
+	public boolean hasAssociatedMarkup()
 	{
 		return getApplication().getMarkupSettings().getMarkupCache().hasAssociatedMarkup(this);
 	}

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java?view=diff&rev=563430&r1=563429&r2=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java Tue Aug  7 01:52:21 2007
@@ -20,7 +20,7 @@
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupException;
 import org.apache.wicket.markup.MarkupStream;
-import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup;
 import org.apache.wicket.markup.parser.XmlTag;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.util.lang.Objects;
@@ -38,18 +38,18 @@
  * <p>
  * 
  * <pre>
- *             &lt;span wicket:id=&quot;myPanel&quot;&gt;Example input (will be removed)&lt;/span&gt;
- *            
- *             &lt;wicket:fragment wicket:id=&quot;frag1&quot;&gt;panel 1&lt;/wicket:fragment&gt;
- *             &lt;wicket:fragment wicket:id=&quot;frag2&quot;&gt;panel 2&lt;/wicket:fragment&gt;
+ *  &lt;span wicket:id=&quot;myPanel&quot;&gt;Example input (will be removed)&lt;/span&gt;
+ *  
+ *  &lt;wicket:fragment wicket:id=&quot;frag1&quot;&gt;panel 1&lt;/wicket:fragment&gt;
+ *  &lt;wicket:fragment wicket:id=&quot;frag2&quot;&gt;panel 2&lt;/wicket:fragment&gt;
  * </pre> 
  * <pre>
- *             add(new Fragment(&quot;myPanel1&quot;, &quot;frag1&quot;);
+ *  add(new Fragment(&quot;myPanel1&quot;, &quot;frag1&quot;);
  * </pre>
  * 
  * @author Juergen Donnerstag
  */
-public class Fragment extends WebMarkupContainer
+public class Fragment extends WebMarkupContainerWithAssociatedMarkup
 {
 	private static final long serialVersionUID = 1L;
 
@@ -210,14 +210,14 @@
 	{
 		MarkupStream stream = null;
 
-		if (this.markupProvider == null)
+		if (markupProvider == null)
 		{
 			stream = markupStream;
 		}
 		else
 		{
 
-			stream = this.markupProvider.getAssociatedMarkupStream(false);
+			stream = markupProvider.getAssociatedMarkupStream(false);
 			if (stream == null)
 			{
 				// The following statement assumes that the markup provider is a
@@ -246,10 +246,10 @@
 		int index = providerMarkupStream.findComponentIndex(null, markupId);
 		if (index == -1)
 		{
-			throw new MarkupException("Markup of component class `"
-					+ providerMarkupStream.getContainerClass().getName()
-					+ "` does not contain a fragment with wicket:id `" + markupId + "`. Context: "
-					+ toString());
+			throw new MarkupException("Markup of component class `" +
+					providerMarkupStream.getContainerClass().getName() +
+					"` does not contain a fragment with wicket:id `" + markupId + "`. Context: " +
+					toString());
 		}
 
 		// Set the markup stream position to where the fragment begins
@@ -273,5 +273,32 @@
 			// at the original component
 			providerMarkupStream.setCurrentIndex(currentIndex);
 		}
+	}
+
+	/**
+	 * @see org.apache.wicket.MarkupContainer#hasAssociatedMarkup()
+	 */
+	public boolean hasAssociatedMarkup()
+	{
+		return true;
+	}
+
+	/**
+	 * @see org.apache.wicket.MarkupContainer#getAssociatedMarkupStream(boolean)
+	 */
+	public MarkupStream getAssociatedMarkupStream(boolean throwException)
+	{
+		MarkupStream stream = null;
+
+		if (markupProvider != null)
+		{
+			stream = markupProvider.getAssociatedMarkupStream(false);
+		}
+
+		if (stream == null)
+		{
+			stream = super.getAssociatedMarkupStream(throwException);
+		}
+		return stream;
 	}
 }

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html?view=auto&rev=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html Tue Aug  7 01:52:21 2007
@@ -0,0 +1,28 @@
+<html xmlns:wicket>
+<head><script type="text/javascript" src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
+<script type="text/javascript" src="resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax.js"></script>
+<script type="text/javascript" id="wicket-ajax-debug-enable"><!--/*--><![CDATA[/*><!--*/
+wicketAjaxDebugEnable=true;
+/*-->]]>*/</script>
+
+<script type="text/javascript" src="resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js"></script>
+</head><body>
+
+<div wicket:id="container">
+  <div wicket:id="fragment">
+  <span wicket:id="fragmentContent" id="fragmentContent0">foo</span>
+</div>
+</div>
+
+<br/>
+
+<div wicket:id="provider"><wicket:panel>
+
+
+
+<a href="#" wicket:id="ajaxRefresh" onclick="var wcall=wicketAjaxGet('?wicket:interface=:0:provider:ajaxRefresh::IBehaviorListener:0:', function() { }.bind(this), function() { }.bind(this));return !wcall;" id="ajaxRefresh1">AJAX refresh</a>
+
+</wicket:panel></div>
+
+</body>
+</html>

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.html?view=auto&rev=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.html Tue Aug  7 01:52:21 2007
@@ -0,0 +1,13 @@
+<html xmlns:wicket>
+<body>
+
+<div wicket:id="container">
+  <div wicket:id="fragment"></div>
+</div>
+
+<br/>
+
+<div wicket:id="provider"></div>
+
+</body>
+</html>

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.java?view=auto&rev=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.java Tue Aug  7 01:52:21 2007
@@ -0,0 +1,40 @@
+/*
+ * 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.panel;
+
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ * 
+ */
+public class InlinePanelPage_7 extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 */
+	public InlinePanelPage_7()
+	{
+		Provider provider = new Provider("provider");
+		WebMarkupContainer container = new WebMarkupContainer("container");
+		provider.addFragment(container, "fragment");
+		add(provider);
+		add(container);
+	}
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_7.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/PanelTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/PanelTest.java?view=diff&rev=563430&r1=563429&r2=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/PanelTest.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/PanelTest.java Tue Aug  7 01:52:21 2007
@@ -87,7 +87,6 @@
 	 */
 	public void testInlinePanel() throws Exception
 	{
-		tester.getApplication().getPageSettings().addComponentResolver(new FragmentResolver());
 		executeTest(InlinePanelPage_1.class, "InlinePanelPageExpectedResult_1.html");
 	}
 
@@ -96,7 +95,6 @@
 	 */
 	public void testInlinePanel_2() throws Exception
 	{
-		tester.getApplication().getPageSettings().addComponentResolver(new FragmentResolver());
 		executeTest(InlinePanelPage_2.class, "InlinePanelPageExpectedResult_2.html");
 	}
 
@@ -105,7 +103,6 @@
 	 */
 	public void testInlinePanel_3() throws Exception
 	{
-		tester.getApplication().getPageSettings().addComponentResolver(new FragmentResolver());
 		executeTest(InlinePanelPage_3.class, "InlinePanelPageExpectedResult_3.html");
 	}
 
@@ -123,7 +120,6 @@
 	 */
 	public void testInlinePanel_5() throws Exception
 	{
-		tester.getApplication().getPageSettings().addComponentResolver(new FragmentResolver());
 		executeTest(InlinePanelPage_5.class, "InlinePanelPageExpectedResult_5.html");
 	}
 
@@ -131,12 +127,10 @@
 	 * @throws Exception
 	 */
 	// TODO FIX this test.
-//	public void testInlinePanel_6() throws Exception
-//	{
-//		tester.getPageSettings().addComponentResolver(new FragmentResolver());
-//		executeTest(InlinePanelPage_6.class, "InlinePanelPageExpectedResult_6.html");
-//	}
-
+// public void testInlinePanel_6() throws Exception
+// {
+// executeTest(InlinePanelPage_6.class, "InlinePanelPageExpectedResult_6.html");
+// }
 	/**
 	 * @throws Exception
 	 */
@@ -144,5 +138,13 @@
 	{
 		executeTest(PanelWithAttributeModifierPage.class,
 				"PanelWithAttributeModifierPageExpectedResult_1.html");
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	public void testInlinePanel_7() throws Exception
+	{
+		executeTest(InlinePanelPage_7.class, "InlinePanelPageExpectedResult_7.html");
 	}
 }

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.html?view=auto&rev=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.html Tue Aug  7 01:52:21 2007
@@ -0,0 +1,11 @@
+<html xmlns:wicket>
+<wicket:panel>
+
+<wicket:fragment wicket:id="fragment">
+  <span wicket:id="fragmentContent"></span>
+</wicket:fragment>
+
+<a wicket:id="ajaxRefresh">AJAX refresh</a>
+
+</wicket:panel>
+</html>
\ No newline at end of file

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.java?view=auto&rev=563430
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.java Tue Aug  7 01:52:21 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.panel;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * 
+ */
+public class Provider extends Panel
+{
+	private static final long serialVersionUID = 1L;
+
+	private Label fragmentContent;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param id
+	 */
+	public Provider(String id)
+	{
+		super(id);
+		add(new AjaxLink("ajaxRefresh")
+		{
+			private static final long serialVersionUID = 1L;
+
+			public void onClick(AjaxRequestTarget target)
+			{
+				target.addComponent(fragmentContent);
+			}
+		});
+	}
+
+	/**
+	 * 
+	 * @param container
+	 * @param id
+	 */
+	public void addFragment(WebMarkupContainer container, String id)
+	{
+		Fragment fragment = new Fragment(id, "fragment", this);
+		fragmentContent = new Label("fragmentContent", "foo");
+		fragmentContent.setOutputMarkupId(true);
+		fragment.add(fragmentContent);
+		container.add(fragment);
+	}
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/panel/Provider.java
------------------------------------------------------------------------------
    svn:eol-style = native