You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/08/02 06:42:15 UTC

svn commit: r427889 - in /tapestry/tapestry4/trunk/tapestry-framework/src: java/org/apache/tapestry/dojo/form/Autocompleter.java js/dojo/src/validate/check.js js/tests/test_form.js js/tests/test_form_validation.js

Author: jkuhnert
Date: Tue Aug  1 21:42:15 2006
New Revision: 427889

URL: http://svn.apache.org/viewvc?rev=427889&view=rev
Log:
Fix for TAPESTRY-1024. dojo.validate.check() isn't really handling the profile object properly as far as JSON is concerned. 
This fix is temporary until I have time to create a patch that handles this for all properties/objects used in dojo.validate.check()
in a more generic way to be submitted to dojo.

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/Autocompleter.java
    tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/Autocompleter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/Autocompleter.java?rev=427889&r1=427888&r2=427889&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/Autocompleter.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/Autocompleter.java Tue Aug  1 21:42:15 2006
@@ -89,6 +89,8 @@
         json.put("mode", MODE_REMOTE);
         json.put("widgetId", getName());
         json.put("name", getName());
+        json.put("searchDelay", getSearchDelay());
+        json.put("fadeTime", getFadeTime());
         
         IAutocompleteModel model = getModel();
         if (model == null)

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js?rev=427889&r1=427888&r2=427889&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js Tue Aug  1 21:42:15 2006
@@ -86,6 +86,10 @@
 		}
 	}
 
+	if (dj_undef(profile, "required") && !(profile.required instanceof Array)) {
+		profile.required=[profile["required"]];
+	}
+
 	// See if required input fields have values missing.
 	if ( profile.required instanceof Array ) {
 		for (var i = 0; i < profile.required.length; i++) { 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js?rev=427889&r1=427888&r2=427889&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js Tue Aug  1 21:42:15 2006
@@ -75,4 +75,4 @@
 	
 	jum.assertTrue("submitCalled", submitCalled);
 	jum.assertEquals("submitName", node.submitname.value, "testSubmit");
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js?rev=427889&r1=427888&r2=427889&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js Tue Aug  1 21:42:15 2006
@@ -34,6 +34,28 @@
 	jum.assertFalse(value, dojo.validate.isRealNumber(value, {places:0,decimal:".",separator:","}));
 }
 
+function test_validate_required(){
+	// A generic form
+	var f = {
+		
+		tx1: {type: "text", value: " 1001 ",  name: "tx1"},
+		tx2: {type: "text", value: " ",  name: "tx2"},
+		tx3: {type: "text", value: "10/19/2005",  name: "tx3"},
+		
+	};
+
+	// Profile for form input
+	var profile = {
+		// required fields
+		required: "tx2"
+	};
+	
+	// results object
+	var results = dojo.validate.check(f, profile);
+	
+	jum.assertTrue("missing_tx2", results.isMissing("tx2"));
+}
+
 /*
 dojo.event.browser.stopEvent=function(e){
 	if (e) {