You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by dr...@apache.org on 2011/01/05 16:44:31 UTC

svn commit: r1055491 - in /tapestry/tapestry5/trunk: tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/ tapestry-beanvalidator/src/test/java/org/example/testapp/pages/ tapestry-beanvalidator/src/test/webapp/ tapestry-c...

Author: drobiazko
Date: Wed Jan  5 15:44:29 2011
New Revision: 1055491

URL: http://svn.apache.org/viewvc?rev=1055491&view=rev
Log:
TAP5-1393: Form component shoould push the BeanValidationContext into the Environment only after onPrepare()

Added:
    tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/OnPrepareDemo.java   (with props)
    tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/OnPrepareDemo.tml
Modified:
    tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/Index.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java

Modified: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java?rev=1055491&r1=1055490&r2=1055491&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java Wed Jan  5 15:44:29 2011
@@ -180,6 +180,25 @@ public class TapestryBeanValidationInteg
     	assertBubbleMessage("loginName", "You must provide at least 5 characters for Login Name.");
     }
     
+    /*
+     * Ensures TAP5-1393 is fixed.
+     */
+    @Test
+    public void form_on_prepare() throws Exception
+    {
+    	start("OnPrepare Demo");
+    	
+    	clickAndWait(SUBMIT);
+    	
+        assertTextPresent("Login Name may not be null", "Secret Password may not be null");
+        
+        type("loginName", "igor");
+    	
+    	clickAndWait(SUBMIT);
+    	
+        assertTextPresent("Login Name size must be between 7 and 10", "Login Name must match \"[0-9]+\"");
+    }
+    
     protected final void assertBubbleMessage(String fieldId, String expected)
     {
         String popupId = fieldId + ":errorpopup";

Added: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/OnPrepareDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/OnPrepareDemo.java?rev=1055491&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/OnPrepareDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/OnPrepareDemo.java Wed Jan  5 15:44:29 2011
@@ -0,0 +1,30 @@
+// Copyright 2011 The Apache Software Foundation
+//
+// Licensed 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.example.testapp.pages;
+
+import org.apache.tapestry5.annotations.Property;
+import org.example.testapp.entities.User;
+
+public class OnPrepareDemo 
+{
+
+	@Property
+	private User user;
+	
+	void onPrepare()
+	{
+		user = new User();
+	}
+	
+}

Propchange: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/java/org/example/testapp/pages/OnPrepareDemo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/Index.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/Index.tml?rev=1055491&r1=1055490&r2=1055491&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/Index.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/Index.tml Wed Jan  5 15:44:29 2011
@@ -21,6 +21,9 @@
             <li>
                 <t:pagelink page="ClientValidationDemo">Client Validation Demo</t:pagelink>
             </li>
+            <li>
+                <t:pagelink page="OnPrepareDemo">OnPrepare Demo</t:pagelink>
+            </li>
         </ul>
     </body>
 </html>

Added: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/OnPrepareDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/OnPrepareDemo.tml?rev=1055491&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/OnPrepareDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/test/webapp/OnPrepareDemo.tml Wed Jan  5 15:44:29 2011
@@ -0,0 +1,19 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
+    <body>
+        <t:form clientValidation="false" validate="user">
+        	<t:errors/>
+        	
+        	<br/>
+        	
+        	<t:textfield t:id="loginName" value="user.userName"/>
+        	
+        	<br/>
+        	
+        	<t:textfield t:id="secretPassword" value="user.password"/>
+
+        	<br/>
+        	<input type="submit" value="Go"/>
+        	
+        </t:form>
+    </body>
+</html>
\ No newline at end of file

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=1055491&r1=1055490&r2=1055491&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 Wed Jan  5 15:44:29 2011
@@ -390,7 +390,6 @@ public class Form implements ClientEleme
 
         environment.push(FormSupport.class, formSupport);
         environment.push(ValidationTracker.class, activeTracker);
-        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
 
         if (autofocus)
         {
@@ -406,6 +405,9 @@ public class Form implements ClientEleme
         resources.triggerEvent(EventConstants.PREPARE_FOR_RENDER, context, null);
 
         resources.triggerEvent(EventConstants.PREPARE, context, null);
+        
+        // Push BeanValidationContext only after the container had a chance to prepare 
+        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
 
         // Save the form element for later, in case we want to write an encoding
         // type attribute.
@@ -519,7 +521,6 @@ public class Form implements ClientEleme
 
         environment.push(ValidationTracker.class, activeTracker);
         environment.push(FormSupport.class, formSupport);
-        environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
 
         Heartbeat heartbeat = new HeartbeatImpl();
 
@@ -535,6 +536,9 @@ public class Form implements ClientEleme
                 return true;
 
             resources.triggerContextEvent(EventConstants.PREPARE, context, eventCallback);
+            
+
+            environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
 
             if (eventCallback.isAborted())
                 return true;