Author: marrink
Date: Mon Apr  7 15:02:10 2008
New Revision: 645708

URL: http://svn.apache.org/viewvc?rev=645708&view=rev
Log:
RESOLVED - issue WICKET-1291: WicketTester Doesn't Support 
setDefaultFormProcessing(false) 
https://issues.apache.org/jira/browse/WICKET-1291

Added:
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
   (with props)
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.html
   (with props)
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.java
   (with props)
Modified:
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=645708&r1=645707&r2=645708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 Mon Apr  7 15:02:10 2008
@@ -44,7 +44,6 @@
 import org.apache.wicket.feedback.FeedbackMessages;
 import org.apache.wicket.feedback.IFeedbackMessageFilter;
 import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Button;
 import org.apache.wicket.markup.html.form.CheckGroup;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.FormComponent;
@@ -1227,7 +1226,8 @@
                {
                        public void onFormComponent(FormComponent formComponent)
                        {
-                               if (!(formComponent instanceof Button) && 
!(formComponent instanceof RadioGroup) &&
+                               // !(formComponent instanceof Button) &&
+                               if (!(formComponent instanceof RadioGroup) &&
                                        !(formComponent instanceof CheckGroup))
                                {
                                        String name = 
formComponent.getInputName();

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java?rev=645708&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
 Mon Apr  7 15:02:10 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.ajax.form;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.util.tester.FormTester;
+
+/**
+ * Test case for WICKET-1291
+ * 
+ * @see <a 
href="https://issues.apache.org/jira/browse/WICKET-1291";>WICKET-1291</a>
+ * @author marrink
+ */
+public class AjaxFormSubmitTest extends WicketTestCase
+{
+
+       /**
+        * @see org.apache.wicket.WicketTestCase#setUp()
+        */
+       protected void setUp() throws Exception
+       {
+               super.setUp();
+       }
+
+       /**
+        * @see org.apache.wicket.WicketTestCase#tearDown()
+        */
+       protected void tearDown() throws Exception
+       {
+               super.tearDown();
+       }
+
+       /**
+        * Test ajax form submit without default form processing.
+        */
+       public void testSubmitNoDefProcessing()
+       {
+               Class pageClass = AjaxFormSubmitTestPage.class;
+               System.out.println("=== " + pageClass.getName() + " ===");
+
+               tester.startPage(pageClass);
+               tester.assertRenderedPage(pageClass);
+               FormTester form = tester.newFormTester("form");
+               form.setValue("txt1", "txt1");
+               form.setValue("txt2", "txt2");
+               tester.executeAjaxEvent("form:submit", "onclick");
+               AjaxFormSubmitTestPage page = 
(AjaxFormSubmitTestPage)tester.getLastRenderedPage();
+               assertFalse((page.getFormSubmitted() & 
AjaxFormSubmitTestPage.FORM) == AjaxFormSubmitTestPage.FORM);
+               assertTrue((page.getFormSubmitted() & 
AjaxFormSubmitTestPage.BUTTON) == AjaxFormSubmitTestPage.BUTTON);
+               assertEquals("foo", 
tester.getComponentFromLastRenderedPage("form:txt1").getModelObject());
+               assertEquals("bar", 
tester.getComponentFromLastRenderedPage("form:txt2").getModelObject());
+       }
+
+}

Propchange: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.html?rev=645708&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.html
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.html
 Mon Apr  7 15:02:10 2008
@@ -0,0 +1,9 @@
+<html>
+       <body>
+               <form wicket:id="form">
+                       <input type="text" wicket:id="txt1"/>
+                       <input type="text" wicket:id="txt2"/>
+                       <input type="submit" value="Submit" wicket:id="submit"/>
+               </form> 
+       </body>
+</html>
\ No newline at end of file

Propchange: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.java?rev=645708&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.java
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.java
 Mon Apr  7 15:02:10 2008
@@ -0,0 +1,84 @@
+/*
+ * 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.ajax.form;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
+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.CompoundPropertyModel;
+import org.apache.wicket.util.value.ValueMap;
+
+/**
+ * @author marrink
+ */
+public class AjaxFormSubmitTestPage extends WebPage
+{
+       /**
+        * Indicates form handled submit.
+        */
+       public static final int FORM = 2;
+       /**
+        * Indicates button handled submit.
+        */
+       public static final int BUTTON = 4;
+
+       private int formSubmitted;
+
+       /**
+        * Returns the component(s) that handled the form submit.
+        * 
+        * @return flag indicating the component(s)
+        */
+       public final int getFormSubmitted()
+       {
+               return formSubmitted;
+       }
+
+       /**
+        * Construct.
+        */
+       public AjaxFormSubmitTestPage()
+       {
+               super(new CompoundPropertyModel(new 
ValueMap("txt1=foo,txt2=bar")));
+               Form form = new Form("form")
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       protected void onSubmit()
+                       {
+                               formSubmitted = formSubmitted | FORM;
+                       }
+               };
+               add(form);
+               form.add(new TextField("txt1"));
+               form.add(new TextField("txt2"));
+               form.add(new AjaxFallbackButton("submit", form)
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       protected void onSubmit(AjaxRequestTarget target, Form 
form)
+                       {
+                               formSubmitted = formSubmitted | BUTTON;
+                       }
+
+               }.setDefaultFormProcessing(false));
+       }
+
+
+}

Propchange: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to