Author: jdonnerstag
Date: Sat Apr  4 09:35:23 2009
New Revision: 761883

URL: http://svn.apache.org/viewvc?rev=761883&view=rev
Log:
fixed WICKET-2134 Conversion Exception Thrown for Submitting A Page with 
Multiple Forms within A Border
Issue: WICKET-2134

Added:
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.html
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.html
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/TestHomePage_2134.java
Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java?rev=761883&r1=761882&r2=761883&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java 
(original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java 
Sat Apr  4 09:35:23 2009
@@ -2009,7 +2009,7 @@
                MarkupContainer border = findParent(Border.class);
                if (border != null)
                {
-                       FormComponent.visitComponentsPostOrder(border, new 
FormModelUpdateVisitor(null));
+                       FormComponent.visitComponentsPostOrder(border, new 
FormModelUpdateVisitor(this));
                }
        }
 

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.html?rev=761883&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.html
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.html
 Sat Apr  4 09:35:23 2009
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+    "http://www.w3.org/TR/html4/loose.dtd";>
+<html xmlns:wicket="http://wicket.apache.org/";>
+<body>
+<wicket:border>
+    <wicket:body />
+</wicket:border>
+</body>
+</html>
\ No newline at end of file

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.java?rev=761883&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.java
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonBorder.java
 Sat Apr  4 09:35:23 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.form.border;
+
+import org.apache.wicket.markup.html.border.Border;
+
+/**
+ *
+ */
+public class CommonBorder extends Border
+{
+       private static final long serialVersionUID = 1L;
+
+       /**
+        * Construct.
+        * 
+        * @param id
+        */
+       public CommonBorder(String id)
+       {
+               super(id);
+       }
+}

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.html?rev=761883&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.html
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.html
 Sat Apr  4 09:35:23 2009
@@ -0,0 +1,14 @@
+<html>
+<body>
+   <div wicket:id="border">
+       <form wicket:id="form1">
+           <input wicket:id="quantity1" /><br/>
+           <input type="submit" value="Quantity1" />
+       </form><br/>
+       <form wicket:id="form2">
+           <input wicket:id="quantity2" /><br/>
+           <input type="submit" value="Quantity2" />
+       </form><br/>
+   </div>
+</body>
+</html>
\ No newline at end of file

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.java?rev=761883&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.java
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/CommonModelPage.java
 Sat Apr  4 09:35:23 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.form.border;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.PropertyModel;
+
+/**
+ * 
+ */
+public class CommonModelPage extends WebPage
+{
+       private static final long serialVersionUID = 1L;
+
+       int quantity1;
+       int quantity2;
+
+       /**
+        * Construct.
+        */
+       public CommonModelPage()
+       {
+               CommonBorder border = new CommonBorder("border");
+               add(border);
+
+               Form form1 = new Form("form1");
+               border.add(form1);
+
+               form1.add(new TextField("quantity1", new PropertyModel(this, 
"quantity1")));
+
+               Form form2 = new Form("form2");
+               border.add(form2);
+
+               form2.add(new TextField("quantity2", new PropertyModel(this, 
"quantity2")));
+       }
+
+       public int getQuantity1()
+       {
+               return quantity1;
+       }
+
+       public void setQuantity1(int quantity1)
+       {
+               this.quantity1 = quantity1;
+       }
+
+       public int getQuantity2()
+       {
+               return quantity2;
+       }
+
+       public void setQuantity2(int quantity2)
+       {
+               this.quantity2 = quantity2;
+       }
+}

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/TestHomePage_2134.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/TestHomePage_2134.java?rev=761883&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/TestHomePage_2134.java
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/TestHomePage_2134.java
 Sat Apr  4 09:35:23 2009
@@ -0,0 +1,97 @@
+/*
+ * 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.form.border;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Simple test using the WicketTester
+ */
+public class TestHomePage_2134 extends TestCase
+{
+       private WicketTester tester;
+
+       @Override
+       public void setUp()
+       {
+               tester = new WicketTester();
+       }
+
+       /**
+        * WICKET-2134: two forms inside a border throw a ConversionException 
error
+        */
+       public void testRenderMyPage()
+       {
+               // start and render the test page
+               tester.startPage(CommonModelPage.class);
+
+               // assert rendered page class
+               tester.assertRenderedPage(CommonModelPage.class);
+
+               FormTester formTester = tester.newFormTester("border:form1");
+               formTester.submit();
+
+               CommonModelPage page = 
(CommonModelPage)tester.getLastRenderedPage();
+               assertEquals(0, page.quantity1);
+               assertEquals(0, page.quantity2);
+       }
+
+       /**
+        * WICKET-2134: two forms inside a border throw a ConversionException 
error
+        */
+       public void testRenderMyPage2()
+       {
+               // start and render the test page
+               tester.startPage(CommonModelPage.class);
+
+               // assert rendered page class
+               tester.assertRenderedPage(CommonModelPage.class);
+
+               FormTester formTester = tester.newFormTester("border:form1");
+               formTester.setValue("quantity1", "123");
+               formTester.setValue("quantity2", "44");
+               formTester.submit();
+
+               CommonModelPage page = 
(CommonModelPage)tester.getLastRenderedPage();
+               assertEquals(123, page.quantity1);
+               assertEquals(0, page.quantity2);
+       }
+
+       /**
+        * WICKET-2134: two forms inside a border throw a ConversionException 
error
+        */
+       public void testRenderMyPage3()
+       {
+               // start and render the test page
+               tester.startPage(CommonModelPage.class);
+
+               // assert rendered page class
+               tester.assertRenderedPage(CommonModelPage.class);
+
+               FormTester formTester = tester.newFormTester("border:form2");
+               formTester.setValue("quantity1", "123");
+               formTester.setValue("quantity2", "44");
+               formTester.submit();
+
+               CommonModelPage page = 
(CommonModelPage)tester.getLastRenderedPage();
+               assertEquals(0, page.quantity1);
+               assertEquals(44, page.quantity2);
+       }
+}


Reply via email to