From 0226f8f5f430d34b3cead40c4eb7b458933d16c6 Mon Sep 17 00:00:00 2001 From: wei <> Date: Wed, 18 Jan 2006 04:20:26 +0000 Subject: update javascript library and usage in web controls --- framework/Web/UI/WebControls/TButton.php | 42 +++++++++++++------------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'framework/Web/UI/WebControls/TButton.php') diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index 0b4f3e37..bffb4009 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -76,16 +76,8 @@ class TButton extends TWebControl implements IPostBackEventHandler $writer->addAttribute('value',$this->getText()); if($this->getEnabled(true)) { - $scripts = $this->getPage()->getClientScript(); - if($scripts->isEndScriptRegistered("TBaseValidator")) - { - $group = $this->getValidationGroup(); - $group = strlen($group) ? ",'".$group."'" : ''; - $clientID=$this->getClientID(); - //$script = "Prado.Validation.AddTarget('{$uniqueID}'{$group});"; - $script = "Prado.Validation.AddTarget('{$clientID}'{$group});"; - $scripts->registerEndScript("{$uniqueID}:target", $script); - } + if($this->canCauseValidation()) + $this->getPage()->getClientScript()->registerPostBackControl($this); } else if($this->getEnabled()) // in this case, parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); @@ -94,26 +86,26 @@ class TButton extends TWebControl implements IPostBackEventHandler parent::addAttributesToRender($writer); } + protected function canCauseValidation() + { + $group = $this->getValidationGroup(); + $hasValidators = $this->getPage()->getValidators($group)->getCount()>0; + return $this->getCausesValidation() && $hasValidators; + } + /** * Returns postback specifications for the button. * This method is used by framework and control developers. - * @return TPostBackOptions parameters about how the button defines its postback behavior. + * @return array parameters about how the button defines its postback behavior. */ - protected function getPostBackOptions() + public function getPostBackOptions() { - $option=new TPostBackOptions(); - $group = $this->getValidationGroup(); - $hasValidators = $this->getPage()->getValidators($group)->getCount()>0; - if($this->getCausesValidation() && $hasValidators) - { - $option->setPerformValidation(true); - $option->setValidationGroup($group); - } - if($this->getPostBackUrl()!=='') - $option->setActionUrl($this->getPostBackUrl()); - $option->setClientSubmit(!$this->getUseSubmitBehavior()); - - return $option; + $options['CausesValidation'] = $this->getCausesValidation(); + $options['ValidationGroup'] = $this->getValidationGroup(); + $options['PostBackUrl'] = $this->getPostBackUrl(); + $options['ClientSubmit'] = !$this->getUseSubmitBehavior(); + + return $options; } /** -- cgit v1.2.3