Author: hlship
Date: Sat Dec 31 01:11:07 2011
New Revision: 1226007

URL: http://svn.apache.org/viewvc?rev=1226007&view=rev
Log:
TAP5-1808:Change Form to (by default) immediately render markup when there are 
validation errors, to avoid creating the session

Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=1226007&r1=1226006&r2=1226007&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
 Sat Dec 31 01:11:07 2011
@@ -106,6 +106,8 @@ public class Form implements ClientEleme
      */
     public static final String SUBMITTING_ELEMENT_ID = "t:submit";
 
+    public static final StreamPageContent STREAM_ACTIVE_PAGE_CONTENT = new 
StreamPageContent().withoutActivation();
+
     /**
      * The context for the link (optional parameter). This list of values will
      * be converted into strings and included in
@@ -540,7 +542,9 @@ public class Form implements ClientEleme
             // submission.
 
             if (!activeTracker.getHasErrors())
+            {
                 activeTracker.clear();
+            }
 
             resources.triggerContextEvent(activeTracker.getHasErrors() ? 
EventConstants.FAILURE
                     : EventConstants.SUCCESS, context, eventCallback);
@@ -553,7 +557,19 @@ public class Form implements ClientEleme
 
             resources.triggerContextEvent(EventConstants.SUBMIT, context, 
eventCallback);
 
-            return eventCallback.isAborted();
+            if (eventCallback.isAborted()) { return true; }
+
+            // For traditional request with no validation exceptions, 
re-render the
+            // current page immediately, as-is.  Prior to Tapestry 5.4, a 
redirect was
+            // sent that required that the tracker be persisted across 
requests.
+            // See https://issues.apache.org/jira/browse/TAP5-1808
+
+            if (activeTracker.getHasErrors() && !request.isXHR()) {
+                return STREAM_ACTIVE_PAGE_CONTENT;
+            }
+
+            return false;
+
         } finally
         {
             environment.pop(Heartbeat.class);


Reply via email to