Add a demo page to test out TAP5-2391

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

Branch: refs/heads/master
Commit: db0255cfc88a9737d0865446155b12d6aa606900
Parents: eff7941
Author: Howard M. Lewis Ship <hls...@apache.org>
Authored: Tue Apr 7 14:55:11 2015 -0700
Committer: Howard M. Lewis Ship <hls...@apache.org>
Committed: Tue Apr 7 14:55:11 2015 -0700

----------------------------------------------------------------------
 .../integration/app1/pages/ZoneFormDemo.groovy  | 65 ++++++++++++++++++++
 .../tapestry5/integration/app1/pages/Index.java |  2 +
 .../integration/app1/pages/ZoneFormDemo.tml     | 24 ++++++++
 3 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db0255cf/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.groovy
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.groovy
 
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.groovy
new file mode 100644
index 0000000..560a0b0
--- /dev/null
+++ 
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.groovy
@@ -0,0 +1,65 @@
+package org.apache.tapestry5.integration.app1.pages
+
+import org.apache.tapestry5.Field
+import org.apache.tapestry5.ValidationTracker
+import org.apache.tapestry5.alerts.AlertManager
+import org.apache.tapestry5.annotations.Environmental
+import org.apache.tapestry5.annotations.InjectComponent
+import org.apache.tapestry5.beaneditor.Validate
+import org.apache.tapestry5.corelib.components.Zone
+import org.apache.tapestry5.ioc.annotations.Inject
+
+/**
+ * Used to demonstrate Ajax updates to a form including decoration.
+ */
+public class ZoneFormDemo {
+
+    @Validate("required")
+    String handle
+
+    @Validate("required")
+    Integer rating
+
+    @InjectComponent
+    Zone zone
+
+    @Inject
+    AlertManager alertManager
+
+    @Environmental
+    ValidationTracker tracker
+
+    @InjectComponent("handle")
+    Field handleField
+
+    @InjectComponent("rating")
+    Field ratingField
+
+    def onValidateFromForm() {
+
+        if (handle.startsWith("x")) {
+            tracker.recordError(handleField, "No X here, please.")
+        }
+
+        if (rating < 3) {
+            tracker.recordError(ratingField, "Too stringy!")
+        }
+
+        if (rating > 8 && !(handle.startsWith("hl"))) {
+            tracker.recordError(ratingField, "Too nice!")
+        }
+    }
+
+    def onSuccessFromForm() {
+
+        alertManager.info("Rated '${handle}' as ${rating}.  Rate another!")
+
+        handle = null
+        rating = null
+    }
+
+    def onSubmitFromForm() {
+        zone.body
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db0255cf/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 4d4c4f3..b14add8 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
@@ -57,6 +57,8 @@ public class Index
 
     private static final List<Item> ITEMS = CollectionFactory
             .newList(
+                    new Item("ZoneFormDemo", "Zone Form Decoration", "Fields 
inside an Ajax-updatd Form are still decorated properly."),
+
                     new Item("AjaxValidationDemo", "Ajax Validation", 
"Demonstrated proper integration of server-side validation and client-side 
field decoration."),
 
                     new Item("OverrideEventHandlerDemo", "Event Handler 
Override Demo", "Event Handler methods overridden by sub-classes invoke 
base-class correctly."),

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db0255cf/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.tml
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.tml
 
b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.tml
new file mode 100644
index 0000000..203ca8b
--- /dev/null
+++ 
b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ZoneFormDemo.tml
@@ -0,0 +1,24 @@
+<html t:type="Border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd";>
+
+    <h1>Zone Form Demo</h1>
+
+    <t:zone t:id="zone" simpleids="true">
+
+        <t:form zone="^" t:id="form">
+
+            <t:errors globalonly="true"/>
+
+            <t:textfield t:id="handle" t:mixins="formgroup" placeholder="Id of 
user to rate"/>
+
+            <t:textfield t:id="rating" t:mixins="formgroup" 
placeholder="Rating"/>
+
+            <div class="row">
+                <t:submit class="btn btn-primary" value="Rate User"/>
+            </div>
+
+        </t:form>
+
+
+    </t:zone>
+
+</html>
\ No newline at end of file

Reply via email to