You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2015/03/18 09:18:58 UTC
[1/2] tapestry-5 git commit: TAP5-2467: Trigger a client-side event
when a form validation fails
Repository: tapestry-5
Updated Branches:
refs/heads/master eed92d68f -> 65b9671c2
TAP5-2467: Trigger a client-side event when a form validation fails
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/9ee2a92f
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/9ee2a92f
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/9ee2a92f
Branch: refs/heads/master
Commit: 9ee2a92fea5cf0e85fba8289502c5b781dca726b
Parents: eed92d6
Author: Charlouze <me...@charlouze.com>
Authored: Fri Mar 13 16:45:44 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Wed Mar 18 09:12:10 2015 +0100
----------------------------------------------------------------------
.../src/main/coffeescript/META-INF/modules/t5/core/events.coffee | 3 +++
.../src/main/coffeescript/META-INF/modules/t5/core/forms.coffee | 4 ++++
2 files changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9ee2a92f/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
index 95af3ab..02187fd 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
@@ -27,6 +27,9 @@ define
# to true to indicate a validation exception occured, and the form submission should be prevented.
validate: "t5:form:validate"
+ # Triggered after fields and form have been validated, when there are field or form validation exceptions.
+ validateInError: "t5:form:validateInError"
+
# Triggered after `validate` (when there are no prior validation exceptions), to allow certain elements
# to configure themselves immediately before the form is submitted. This exists primarily for components such
# as FormFragment, which will enable or disable a hidden field to match the visibility of the fragment.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9ee2a92f/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
index fb69d9e..c8de264 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
@@ -141,6 +141,10 @@ define ["./events", "./dom", "underscore"],
# focus on it.
focusField.focus() if focusField
+ # Trigger an event to inform that form validation results in error
+ where = -> "triggering validation in error event"
+ @trigger events.form.validateInError
+
# Cancel the original submit event when there's an error
return false
[2/2] tapestry-5 git commit: TAP5-2467: Test for the JS event when
client side form validation fails
Posted by jk...@apache.org.
TAP5-2467: Test for the JS event when client side form validation fails
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/65b9671c
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/65b9671c
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/65b9671c
Branch: refs/heads/master
Commit: 65b9671c244ebca826de6958264aa5f4b8de7c7d
Parents: 9ee2a92
Author: Charlouze <me...@charlouze.com>
Authored: Tue Mar 17 20:08:01 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Wed Mar 18 09:13:20 2015 +0100
----------------------------------------------------------------------
tapestry-core/src/test/app1/ValidateInErrorEvent.tml | 6 ++++++
.../META-INF/modules/validate-in-error.coffee | 7 +++++++
.../org/apache/tapestry5/integration/app1/FormTests.java | 11 +++++++++++
.../apache/tapestry5/integration/app1/pages/Index.java | 5 ++++-
.../integration/app1/pages/ValidateInErrorEvent.java | 10 ++++++++++
5 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/ValidateInErrorEvent.tml b/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
new file mode 100644
index 0000000..c4b0d12
--- /dev/null
+++ b/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
@@ -0,0 +1,6 @@
+<html t:type="border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<t:form>
+ <t:textfield value="value" validate="required"/>
+ <t:submit/>
+</t:form>
+</html>
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
new file mode 100644
index 0000000..75edfe8
--- /dev/null
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
@@ -0,0 +1,7 @@
+define ['t5/core/dom', 't5/core/events'], (dom, events)->
+ dom.onDocument events.form.validateInError, 'form', ->
+ attributes =
+ id: 'validate-in-error'
+ @prepend dom.create 'div', attributes, 'Validate in error'
+ return
+ return
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
index 70f77e7..4f8a55f 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
@@ -1230,4 +1230,15 @@ public class FormTests extends App1TestCase
assertTextPresent("This parameter is not allowed to be null.");
}
+ /** TAP5-2467 **/
+ @Test
+ public void validate_in_error_event() {
+ openLinks("Validate in error Event");
+
+ click(SUBMIT);
+
+ waitForElementToAppear("validate-in-error");
+
+ assertTextPresent("Validate in error");
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index f146ec1..3c75ce7 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -585,7 +585,10 @@ public class Index
new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context"),
- new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null")
+ new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null"),
+
+ new Item("validateInErrorEvent", "Validate in error Event", "A form that trigger validate in " +
+ "error event on submit when textfield is empty")
);
static
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
new file mode 100644
index 0000000..645703a
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
@@ -0,0 +1,10 @@
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Import;
+import org.apache.tapestry5.annotations.Property;
+
+@Import(module = {"validate-in-error"})
+public class ValidateInErrorEvent {
+ @Property
+ private String value;
+}
[2/2] tapestry-5 git commit: TAP5-2467: Test for the JS event when
client side form validation fails
Posted by jk...@apache.org.
TAP5-2467: Test for the JS event when client side form validation fails
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/65b9671c
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/65b9671c
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/65b9671c
Branch: refs/heads/master
Commit: 65b9671c244ebca826de6958264aa5f4b8de7c7d
Parents: 9ee2a92
Author: Charlouze <me...@charlouze.com>
Authored: Tue Mar 17 20:08:01 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Wed Mar 18 09:13:20 2015 +0100
----------------------------------------------------------------------
tapestry-core/src/test/app1/ValidateInErrorEvent.tml | 6 ++++++
.../META-INF/modules/validate-in-error.coffee | 7 +++++++
.../org/apache/tapestry5/integration/app1/FormTests.java | 11 +++++++++++
.../apache/tapestry5/integration/app1/pages/Index.java | 5 ++++-
.../integration/app1/pages/ValidateInErrorEvent.java | 10 ++++++++++
5 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/ValidateInErrorEvent.tml b/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
new file mode 100644
index 0000000..c4b0d12
--- /dev/null
+++ b/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
@@ -0,0 +1,6 @@
+<html t:type="border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<t:form>
+ <t:textfield value="value" validate="required"/>
+ <t:submit/>
+</t:form>
+</html>
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
new file mode 100644
index 0000000..75edfe8
--- /dev/null
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
@@ -0,0 +1,7 @@
+define ['t5/core/dom', 't5/core/events'], (dom, events)->
+ dom.onDocument events.form.validateInError, 'form', ->
+ attributes =
+ id: 'validate-in-error'
+ @prepend dom.create 'div', attributes, 'Validate in error'
+ return
+ return
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
index 70f77e7..4f8a55f 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
@@ -1230,4 +1230,15 @@ public class FormTests extends App1TestCase
assertTextPresent("This parameter is not allowed to be null.");
}
+ /** TAP5-2467 **/
+ @Test
+ public void validate_in_error_event() {
+ openLinks("Validate in error Event");
+
+ click(SUBMIT);
+
+ waitForElementToAppear("validate-in-error");
+
+ assertTextPresent("Validate in error");
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index f146ec1..3c75ce7 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -585,7 +585,10 @@ public class Index
new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context"),
- new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null")
+ new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null"),
+
+ new Item("validateInErrorEvent", "Validate in error Event", "A form that trigger validate in " +
+ "error event on submit when textfield is empty")
);
static
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
new file mode 100644
index 0000000..645703a
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
@@ -0,0 +1,10 @@
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Import;
+import org.apache.tapestry5.annotations.Property;
+
+@Import(module = {"validate-in-error"})
+public class ValidateInErrorEvent {
+ @Property
+ private String value;
+}