summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
authorxue <>2006-01-21 22:20:51 +0000
committerxue <>2006-01-21 22:20:51 +0000
commit64d353d1680539fdf3c2d57150f3e93f9f45d84f (patch)
treea2ecad97bbfede61b653b6bd12825b5a6b987083 /framework/Web/UI/WebControls
parentb952f7700884dab38054025ab3b222f4ecf2b5d9 (diff)
Fixed TImageButton about postbackoptions.
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r--framework/Web/UI/WebControls/TButton.php14
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php62
2 files changed, 42 insertions, 34 deletions
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index 968a783a..b8956739 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -75,12 +75,14 @@ class TButton extends TWebControl implements IPostBackEventHandler
if($this->getEnabled(true))
{
if($this->canCauseValidation())
+ {
+ $writer->addAttribute('id',$this->getClientID());
$this->getPage()->getClientScript()->registerPostBackControl($this);
+ }
}
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
- $writer->addAttribute('id',$this->getClientID());
parent::addAttributesToRender($writer);
}
@@ -89,9 +91,13 @@ class TButton extends TWebControl implements IPostBackEventHandler
*/
protected function canCauseValidation()
{
- $group = $this->getValidationGroup();
- $hasValidators = $this->getPage()->getValidators($group)->getCount()>0;
- return $this->getCausesValidation() && $hasValidators;
+ if($this->getCausesValidation())
+ {
+ $group=$this->getValidationGroup();
+ return $this->getPage()->getValidators($group)->getCount()>0;
+ }
+ else
+ return false;
}
/**
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index dfa1752c..72a7df61 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -89,10 +89,11 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
$writer->addAttribute('name',$uniqueID);
if($this->getEnabled(true))
{
- $scripts = $this->getPage()->getClientScript();
- $options = $this->getPostBackOptions();
- $postback = $scripts->getPostBackEventReference($this, '', $options, false);
- $scripts->registerClientEvent($this, "click", $postback);
+ if($this->canCauseValidation())
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getPage()->getClientScript()->registerPostBackControl($this);
+ }
}
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
@@ -100,21 +101,29 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
+ * @return boolean whether to perform validation if the button is clicked
+ */
+ protected function canCauseValidation()
+ {
+ if($this->getCausesValidation())
+ {
+ $group=$this->getValidationGroup();
+ return $this->getPage()->getValidators($group)->getCount()>0;
+ }
+ else
+ return false;
+ }
+
+ /**
* 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.
*/
public function getPostBackOptions()
{
- $options=new TPostBackOptions();
- if($this->getCausesValidation() && $this->getPage()->getValidators($this->getValidationGroup())->getCount()>0)
- {
- $options->setPerformValidation(true);
- $options->setValidationGroup($this->getValidationGroup());
- }
- if($this->getPostBackUrl()!=='')
- $options->setActionUrl($this->getPostBackUrl());
- $options->setClientSubmit(false);
+ $options['CausesValidation'] = $this->getCausesValidation();
+ $options['ValidationGroup'] = $this->getValidationGroup();
+
return $options;
}
@@ -254,22 +263,6 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
- * @return string the URL of the page to post to when the button is clicked, default is empty meaning post to the current page itself
- */
- public function getPostBackUrl()
- {
- return $this->getViewState('PostBackUrl','');
- }
-
- /**
- * @param string the URL of the page to post to from the current page when the button is clicked, empty if post to the current page itself
- */
- public function setPostBackUrl($value)
- {
- $this->setViewState('PostBackUrl',$value,'');
- }
-
- /**
* @return string caption of the button
*/
public function getText()
@@ -297,6 +290,15 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
parent::onPreRender($param);
$this->getPage()->registerRequiresPostData($this);
}
+
+ /**
+ * Renders the body content enclosed between the control tag.
+ * This overrides the parent implementation with nothing to be rendered.
+ * @param THtmlWriter the writer used for the rendering purpose
+ */
+ protected function renderContents($writer)
+ {
+ }
}
/**