summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2005-12-13 15:14:38 +0000
committerxue <>2005-12-13 15:14:38 +0000
commit1ed5d8c3f241116df31b92031ae18a2e6b5b3d4c (patch)
treea1a6b303f83294e17c4c20fb2e2b483a4e3d3d22 /framework/Web
parent597dcf809dac8ba80bf754dc5e02f8b7ff370c8b (diff)
Moved code for registering postback js from onPreRender to addAttributesToRender. It's too early to register js in onPreRender.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/UI/WebControls/TButton.php19
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php31
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php9
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php19
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php9
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php22
6 files changed, 41 insertions, 68 deletions
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index 3a92d809..735c3b50 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -74,19 +74,6 @@ class TButton extends TWebControl implements IPostBackEventHandler
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
$writer->addAttribute('value',$this->getText());
- if(!$this->getEnabled(true) && $this->getEnabled()) // in this case, parent will not render 'disabled'
- $writer->addAttribute('disabled','disabled');
- parent::addAttributesToRender($writer);
- }
-
- /**
- * Registers the postback javascript code.
- * If you override this method, be sure to call the parent implementation
- * so that the event handlers can be invoked.
- * @param TEventParameter event parameter to be passed to the event handlers
- */
- protected function onPreRender($param)
- {
if($this->getEnabled(true))
{
$scripts = $this->getPage()->getClientScript();
@@ -94,7 +81,9 @@ class TButton extends TWebControl implements IPostBackEventHandler
$postback = $scripts->getPostBackEventReference($this, '', $options, false);
$scripts->registerClientEvent($this, "click", $postback);
}
- parent::onPreRender($param);
+ else if($this->getEnabled()) // in this case, parent will not render 'disabled'
+ $writer->addAttribute('disabled','disabled');
+ parent::addAttributesToRender($writer);
}
/**
@@ -115,7 +104,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
if($this->getPostBackUrl()!=='')
$option->setActionUrl($this->getPostBackUrl());
$option->setClientSubmit(!$this->getUseSubmitBehavior());
-
+
return $option;
}
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index ba3a45f7..2f51d8f5 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -51,13 +51,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
- */
- protected function addAttributesToRender($writer)
- {
- // TODO: add display inline block
- }
-
- /**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
@@ -108,9 +101,9 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
* Registers the checkbox to receive postback data during postback.
* This is necessary because a checkbox if unchecked, when postback,
* does not have direct mapping between post data and the checkbox name.
- *
+ *
* Auto-postback javascript code is also registered here.
- *
+ *
* This method overrides the parent implementation and is invoked before render.
* @param mixed event parameter
*/
@@ -119,15 +112,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
parent::onPreRender($param);
if($this->getEnabled(true))
$this->getPage()->registerRequiresPostData($this);
-
- if($this->getAutoPostBack()
- && $this->getPage()->getClientSupportsJavaScript())
- {
- $options = $this->getAutoPostBackOptions();
- $scripts = $this->getPage()->getClientScript();
- $postback = $scripts->getPostBackEventReference($this,'',$options,false);
- $scripts->registerClientEvent($this, "click", $postback);
- }
}
/**
@@ -364,7 +348,16 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$writer->addAttribute('checked','checked');
if(!$this->getEnabled(true))
$writer->addAttribute('disabled','disabled');
+
$page=$this->getPage();
+ if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ {
+ $options = $this->getAutoPostBackOptions();
+ $scripts = $page->getClientScript();
+ $postback = $scripts->getPostBackEventReference($this,'',$options,false);
+ $scripts->registerClientEvent($this, "click", $postback);
+ }
+
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
if(($tabindex=$this->getTabIndex())>0)
@@ -377,7 +370,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
/**
* Sets the post back options for this textbox.
- * @return TPostBackOptions
+ * @return TPostBackOptions
*/
protected function getAutoPostBackOptions()
{
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index de3d1056..f4d61855 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -89,7 +89,14 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
$writer->addAttribute('type','image');
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
- if(!$this->getEnabled(true) && $this->getEnabled()) // in this case, parent will not render 'disabled'
+ if($this->getEnabled(true))
+ {
+ $scripts = $this->getPage()->getClientScript();
+ $options = $this->getPostBackOptions();
+ $postback = $scripts->getPostBackEventReference($this, '', $options, false);
+ $scripts->registerClientEvent($this, "click", $postback);
+ }
+ else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
}
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index 121e6213..d3518ee4 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -81,35 +81,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler
// We call parent implementation here because some attributes
// may be overwritten in the following
parent::addAttributesToRender($writer);
-
+
if($this->getEnabled(true))
{
$url = $this->getPostBackUrl();
//create unique no-op url references
$nop = "javascript:;//{$this->ClientID}";
$writer->addAttribute('href', $url ? $url : $nop);
- }
- else if($this->getEnabled()) // in this case, parent will not render 'disabled'
- $writer->addAttribute('disabled','disabled');
- }
- /**
- * Registers the postback javascript code.
- * If you override this method, be sure to call the parent implementation
- * so that the event handlers can be invoked.
- * @param TEventParameter event parameter to be passed to the event handlers
- */
- protected function onPreRender($param)
- {
- if($this->getEnabled(true))
- {
$scripts = $this->getPage()->getClientScript();
$options = $this->getPostBackOptions();
$postback = $scripts->getPostBackEventReference($this, '', $options, false);
$code = "{$postback}; Event.stop(e);";
$scripts->registerClientEvent($this, "click", $code);
}
- parent::onPreRender($param);
+ else if($this->getEnabled()) // in this case, parent will not render 'disabled'
+ $writer->addAttribute('disabled','disabled');
}
/**
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index 153da8e6..78dc6549 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -152,7 +152,16 @@ class TRadioButton extends TCheckBox
$writer->addAttribute('checked','checked');
if(!$this->getEnabled(true))
$writer->addAttribute('disabled','disabled');
+
$page=$this->getPage();
+ if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ {
+ $options = $this->getAutoPostBackOptions();
+ $scripts = $page->getClientScript();
+ $postback = $scripts->getPostBackEventReference($this,'',$options,false);
+ $scripts->registerClientEvent($this, "click", $postback);
+ }
+
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
if(($tabindex=$this->getTabIndex())>0)
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index 1ad736db..905cc1e1 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -117,22 +117,10 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
$writer->addAttribute('readonly','readonly');
if(!$this->getEnabled(true) && $this->getEnabled()) // in this case parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
- parent::addAttributesToRender($writer);
- }
-
- /**
- * Registers the auto-postback javascript code.
- * If you override this method, be sure to call the parent implementation
- * so that the event handlers can be invoked.
- * @param TEventParameter event parameter to be passed to the event handlers
- */
- protected function onPreRender($param)
- {
- if($this->getAutoPostBack()
- && $this->getPage()->getClientSupportsJavaScript())
+ if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
{
$options = $this->getAutoPostBackOptions();
- $scripts = $this->getPage()->getClientScript();
+ $scripts = $this->getPage()->getClientScript();
$postback = $scripts->getPostBackEventReference($this,'',$options,false);
$scripts->registerClientEvent($this, "change", $postback);
@@ -142,12 +130,12 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
$scripts->registerClientEvent($this, "keypress", $code);
}
}
- parent::onPreRender($param);
+ parent::addAttributesToRender($writer);
}
-
+
/**
* Sets the post back options for this textbox.
- * @return TPostBackOptions
+ * @return TPostBackOptions
*/
protected function getAutoPostBackOptions()
{