summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortof <>2008-03-14 14:42:39 +0000
committertof <>2008-03-14 14:42:39 +0000
commit3d8d3f7169814c33c1dc829ef61cb3281d8c146c (patch)
tree3a85b3eb1b327d79ce549808ffb95f7c86f2239a
parentef2989e39255dba36cbbf20a1c5400fe7667ed26 (diff)
Fixed #671, #721
-rw-r--r--HISTORY2
-rw-r--r--framework/Web/Javascripts/source/prado/validator/validation3.js58
2 files changed, 57 insertions, 3 deletions
diff --git a/HISTORY b/HISTORY
index 67147293..26544969 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,8 +1,10 @@
Version 3.1.2 To be released
============================
BUG: Ticket#636 - I18N catalogue problem (Christophe)
+BUG: Ticket#671 - TActiveCustomValidator Callback Problem (Christophe)
BUG: Ticket#707 - TPropertyAccess sets property twice on object when using setters (Qiang)
BUG: Ticket#719 - TAutoCompleter should not trigger Validation if CausesValidation=False (Christophe)
+BUG: Ticket#721 - TActiveCustomValidator + TValidationSummary problem (Christophe)
BUG: Ticket#736 - Files never created in clientscript.php (Qiang)
BUG: Ticket#744 - Callback error handling is improved (Qiang)
BUG: Ticket#747 - TRangeValidator accept letters when type Integer is specified (Christophe)
diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js
index 45e9aa43..47c031c4 100644
--- a/framework/Web/Javascripts/source/prado/validator/validation3.js
+++ b/framework/Web/Javascripts/source/prado/validator/validation3.js
@@ -410,8 +410,11 @@ Prado.WebUI.TValidationSummary.prototype =
return;
}
- var refresh = update || this.visible == false || this.options.Refresh != false;
-
+ var refresh = update || this.visible == false || this.options.Refresh != false;
+ // Also, do not refresh summary if at least 1 validator is waiting for callback response.
+ // This will avoid the flickering of summary if the validator passes its test
+ refresh = refresh && validators.any(function(v) { return !v.requestDispatched; });
+
if(this.options.ShowSummary != false && refresh)
{
this.updateHTMLMessages(this.getMessages(validators));
@@ -1150,15 +1153,57 @@ Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
validatingValue : null,
+ invoker : null,
/**
+ * Override the parent implementation to store the invoker, in order to
+ * re-validate after the callback has returned
+ * Calls evaluateIsValid() function to set the value of isValid property.
+ * Triggers onValidate event and onSuccess or onError event.
+ * @param HTMLElement element that calls for validation
+ * @return boolean true if valid.
+ */
+ validate : function(invoker)
+ {
+ this.invoker = invoker;
+
+ //try to find the control.
+ if(!this.control)
+ this.control = $(this.options.ControlToValidate);
+
+ if(!this.control || this.control.disabled)
+ {
+ this.isValid = true;
+ return this.isValid;
+ }
+
+ if(typeof(this.options.OnValidate) == "function")
+ {
+ if(this.requestDispatched == false)
+ this.options.OnValidate(this, invoker);
+ }
+
+ if(this.enabled && !this.control.getAttribute('disabled'))
+ this.isValid = this.evaluateIsValid();
+ else
+ this.isValid = true;
+
+ // Only update the message if the callback has already return !
+ if (!this.requestDispatched)
+ this.updateValidationDisplay(invoker);
+
+ this.observeChanges(this.control);
+
+ return this.isValid;
+ },
+
+ /**
* Calls custom validation function.
*/
evaluateIsValid : function()
{
value = this.getValidationValue();
if(!this.requestDispatched && (""+value) != (""+this.validatingValue))
- //if((""+value) != (""+this.validatingValue))
{
this.validatingValue = value;
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
@@ -1182,6 +1227,13 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
if(typeof(this.options.onSuccess) == "function")
this.options.onSuccess(request,data);
this.updateValidationDisplay();
+ this.manager.updateSummary(this.group);
+ // Redispatch initial request if any
+ if (this.invoker instanceof Prado.CallbackRequest)
+ {
+ this.invoker.dispatch();
+ }
+
},
callbackOnFailure : function(request, data)