Updated Branches:
  refs/heads/5.4-js-rewrite e0dd5d2b6 -> 3cc722f01

Properly distinguish between cancel and unconditional submit


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/3cc722f0
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/3cc722f0
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/3cc722f0

Branch: refs/heads/5.4-js-rewrite
Commit: 3cc722f010111761d19011e03ac02d92c03b71ad
Parents: 6710c07
Author: Howard M. Lewis Ship <[email protected]>
Authored: Tue Nov 27 17:51:49 2012 +0000
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Tue Nov 27 17:51:49 2012 +0000

----------------------------------------------------------------------
 .../META-INF/modules/core/forms.coffee             |    6 ++--
 .../app1/SubmitUnconditionalTests.groovy           |   28 ++++++++------
 .../integration/TapestryCoreTestCase.java          |    6 +++
 3 files changed, 25 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3cc722f0/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee 
b/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee
index c6bc444..5b290a0 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee
@@ -36,8 +36,8 @@ define ["core/events", "core/dom", "core/builder", "_"],
     setSubmittingHidden = (form, submitter) ->
 
       mode = submitter.attribute "data-submit-mode"
-      isCancel = mode and mode isnt "normal"
-      if isCancel
+      isCancel = mode is "cancel"
+      if mode and mode isnt "normal"
         form.meta SKIP_VALIDATION, true
 
       hidden = form.findFirst "[name='t:submit']"
@@ -48,7 +48,7 @@ define ["core/events", "core/dom", "core/builder", "_"],
         firstHidden.insertBefore hidden
 
       # TODO: Research why we need id and name and get rid of one if possible.
-      name = if isCancel then "cancel" else submitted.element.name
+      name = if isCancel then "cancel" else submitter.element.name
       value = Object.toJSON [ submitter.element.id, name ]
 
       hidden.value value

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3cc722f0/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/SubmitUnconditionalTests.groovy
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/SubmitUnconditionalTests.groovy
 
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/SubmitUnconditionalTests.groovy
index d457ce5..13c13d7 100644
--- 
a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/SubmitUnconditionalTests.groovy
+++ 
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/SubmitUnconditionalTests.groovy
@@ -6,22 +6,26 @@ import org.testng.annotations.Test
 
 class SubmitUnconditionalTests extends TapestryCoreTestCase {
 
-  @Test
-  void submit_with_unconditional_mode() {
-    openLinks "Cancel Demo"
+    @Test
+    void submit_with_unconditional_mode() {
+        openLinks "Cancel Demo"
 
-    clickAndWait "//input[@value='Abort']"
+        sleep SETUP_TIME
 
-    assertText "message", "onSelectedFromAbort() invoked."
-  }
+        clickAndWait "//input[@value='Abort']"
 
-  @Test
-  void LinkSubmit_with_unconditional_mode() {
+        assertText "message", "onSelectedFromAbort() invoked."
+    }
 
-    openLinks "Cancel Demo"
+    @Test
+    void LinkSubmit_with_unconditional_mode() {
 
-    clickAndWait "link=Abort"
+        openLinks "Cancel Demo"
 
-    assertText "message", "onSelectedFromAbortLink() invoked."
-  }
+        sleep SETUP_TIME
+
+        clickAndWait "link=Abort"
+
+        assertText "message", "onSelectedFromAbortLink() invoked."
+    }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3cc722f0/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
 
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
index 55b379f..96058ae 100644
--- 
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
+++ 
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/TapestryCoreTestCase.java
@@ -23,6 +23,12 @@ public abstract class TapestryCoreTestCase extends 
SeleniumTestCase
     public static final String EXCEPTION_PROCESSING_REQUEST = "An exception 
has occurred processing this request.";
     public static final String TEST_APP_BANNER = "Tapestry Integration Test 
Application";
 
+    /**
+     * Number of milliseconds to sleep after the page has loaded, when giving 
JavaScript a chance to fully initialize.
+     * Perhaps we need another option, say one that sets a flag on the HTML 
element once the initializations are complete.
+     */
+    public static final int SETUP_TIME = 100;
+
     protected final void assertTextSeries(String idFormat, int startIndex, 
String... values)
     {
         for (int i = 0; i < values.length; i++)

Reply via email to