summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TButton.php
diff options
context:
space:
mode:
authorwei <>2006-01-18 04:20:26 +0000
committerwei <>2006-01-18 04:20:26 +0000
commit0226f8f5f430d34b3cead40c4eb7b458933d16c6 (patch)
tree68b21c4bec09ed73edc64019b4e20a2e3853d477 /framework/Web/UI/WebControls/TButton.php
parente2219c91b98088289080bfa451d3083851eddf76 (diff)
update javascript library and usage in web controls
Diffstat (limited to 'framework/Web/UI/WebControls/TButton.php')
-rw-r--r--framework/Web/UI/WebControls/TButton.php42
1 files changed, 17 insertions, 25 deletions
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;
}
/**