From 3d8d3f7169814c33c1dc829ef61cb3281d8c146c Mon Sep 17 00:00:00 2001 From: tof <> Date: Fri, 14 Mar 2008 14:42:39 +0000 Subject: Fixed #671, #721 --- .../source/prado/validator/validation3.js | 58 ++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) (limited to 'framework/Web/Javascripts/source') 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,7 +1153,50 @@ 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. */ @@ -1158,7 +1204,6 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, { 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) -- cgit v1.2.3