From fbbc9d2a517f97b9d961e19e0c205a8153e3a093 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 15 Jun 2006 02:13:39 +0000 Subject: Added OnValidate, OnError, OnSuccess events to validators --- HISTORY | 1 + framework/Web/UI/WebControls/TBaseValidator.php | 38 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 818bfd41..2534b883 100644 --- a/HISTORY +++ b/HISTORY @@ -6,6 +6,7 @@ BUG: Ticket#213 - PRADO Requirements Checker charset error (Qiang) CHG: ensureChildControls() is now invoked in TControl::initRecursive (Qiang) CHG: Postback enabled control will always disable default client-side browser action. (Qiang) CHG: CSS and JS files in a theme are now included in page in alphabetic order (Qiang) +ENH: Ticket#206 - Added OnValidate, OnError, OnSuccess events to validators (Qiang) ENH: TRepeater, TDataList and TDataGrid will store data indices in DataKeys if DataKeyField is not set. (Qiang) ENH: Added TPageService.BasePageClass property (Qiang) diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 54fea2ec..3b2f0ec6 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -473,10 +473,22 @@ abstract class TBaseValidator extends TLabel implements IValidator */ public function validate() { + $this->onValidate(); $this->setIsValid(true); $control=$this->getValidationTarget(); if($control && $this->getVisible(true) && $this->getEnabled()) - $this->setIsValid($this->evaluateIsValid()); + { + if($this->evaluateIsValid()) + { + $this->setIsValid(true); + $this->onSuccess(); + } + else + { + $this->setIsValid(false); + $this->onError(); + } + } return $this->getIsValid(); } @@ -503,6 +515,30 @@ abstract class TBaseValidator extends TLabel implements IValidator */ abstract protected function evaluateIsValid(); + /** + * This event is raised when the validator succeeds in validation. + */ + public function onSuccess() + { + $this->raiseEvent('OnSuccess',$this,null); + } + + /** + * This event is raised when the validator fails in validation. + */ + public function onError() + { + $this->raiseEvent('OnError',$this,null); + } + + /** + * This event is raised right before the validator starts to perform validation. + */ + public function onValidate() + { + $this->raiseEvent('OnValidate',$this,null); + } + /** * Renders the validator control. * @param THtmlWriter writer for the rendering purpose -- cgit v1.2.3