From a7f6c6640ac9295eec3ae2edbb2250179eb85e33 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 6 May 2006 02:26:20 +0000 Subject: Adding TActiveButton and TActiveTextBox --- framework/Web/UI/WebControls/TBulletedList.php | 11 ++++++++++- framework/Web/UI/WebControls/TButton.php | 23 +++++++++++++++-------- framework/Web/UI/WebControls/TCheckBox.php | 11 ++++++++++- framework/Web/UI/WebControls/TImageButton.php | 20 +++++++++++++------- framework/Web/UI/WebControls/TImageMap.php | 11 ++++++++++- framework/Web/UI/WebControls/TLinkButton.php | 19 +++++++++++++------ framework/Web/UI/WebControls/TListControl.php | 15 +++++++++++---- framework/Web/UI/WebControls/TRadioButton.php | 11 ++++++++++- framework/Web/UI/WebControls/TTextBox.php | 15 +++++++++++---- 9 files changed, 103 insertions(+), 33 deletions(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php index 05cbaab1..fad77232 100644 --- a/framework/Web/UI/WebControls/TBulletedList.php +++ b/framework/Web/UI/WebControls/TBulletedList.php @@ -321,9 +321,9 @@ class TBulletedList extends TListControl implements IPostBackEventHandler else { $this->_currentRenderItemIndex = $index; - $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TBulletedList',$this->getPostBackOptions()); $writer->addAttribute('id', $this->getClientID().$index); $writer->addAttribute('href', "javascript:;//".$this->getClientID().$index); + $this->renderClientControlScript($writer); } if(($accesskey=$this->getAccessKey())!=='') $writer->addAttribute('accesskey',$accesskey); @@ -331,6 +331,15 @@ class TBulletedList extends TListControl implements IPostBackEventHandler $writer->write(THttpUtility::htmlEncode($item->getText())); $writer->renderEndTag(); } + + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } /** * @return array postback options used for linkbuttons. diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index b9872a64..ba523168 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -72,20 +72,27 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr if(($uniqueID=$this->getUniqueID())!=='') $writer->addAttribute('name',$uniqueID); $writer->addAttribute('value',$this->getText()); - if($this->getEnabled(true)) - { - if($this->canCauseValidation()) - { - $writer->addAttribute('id',$this->getClientID()); - $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TButton',$this->getPostBackOptions()); - } - } + if($this->getEnabled(true) ) + $this->renderClientControlScript($writer); else if($this->getEnabled()) // in this case, parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); parent::addAttributesToRender($writer); } + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + if($this->canCauseValidation()) + { + $writer->addAttribute('id',$this->getClientID()); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } + } + /** * @return boolean whether to perform validation if the button is clicked */ diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index da389948..cb8fb30d 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -351,7 +351,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $page=$this->getPage(); if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) - $page->getClientScript()->registerPostBackControl('Prado.WebUI.TCheckBox',$this->getPostBackOptions()); + $this->renderClientControlScript($writer); if(($accesskey=$this->getAccessKey())!=='') $writer->addAttribute('accesskey',$accesskey); @@ -363,6 +363,15 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $writer->renderEndTag(); } + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } + /** * Gets the post back options for this checkbox. * @return array diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index 109f53a8..4b482721 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -88,18 +88,24 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven if(($uniqueID=$this->getUniqueID())!=='') $writer->addAttribute('name',$uniqueID); if($this->getEnabled(true)) - { - if($this->canCauseValidation()) - { - $writer->addAttribute('id',$this->getClientID()); - $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TImageButton',$this->getPostBackOptions()); - } - } + $this->renderClientControlScript($writer); else if($this->getEnabled()) // in this case, parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); parent::addAttributesToRender($writer); } + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + if($this->canCauseValidation()) + { + $writer->addAttribute('id',$this->getClientID()); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } + } /** * @return boolean whether to perform validation if the button is clicked */ diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php index 9444df46..ae2d6be3 100644 --- a/framework/Web/UI/WebControls/TImageMap.php +++ b/framework/Web/UI/WebControls/TImageMap.php @@ -109,7 +109,7 @@ class TImageMap extends TImage implements IPostBackEventHandler $options['EventParameter']="$i"; $options['CausesValidation']=$hotspot->getCausesValidation(); $options['ValidationGroup']=$hotspot->getValidationGroup(); - $cs->registerPostBackControl('Prado.WebUI.TImageMap',$options); + $cs->renderClientControlScript($writer,$options); } $hotspot->render($writer); $writer->writeLine(); @@ -118,6 +118,15 @@ class TImageMap extends TImage implements IPostBackEventHandler $writer->renderEndTag(); } } + + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer,$options) + { + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$options); + } /** * Raises the postback event. diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index bca4a8f6..7f9baab8 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -81,15 +81,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC parent::addAttributesToRender($writer); if($this->getEnabled(true)) - { - //create unique no-op url references - $nop = "#".$this->getClientID(); - $writer->addAttribute('href', $nop); - $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TLinkButton',$this->getPostBackOptions()); - } + $this->renderClientControlScript($writer); else if($this->getEnabled()) // in this case, parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); } + + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + //create unique no-op url references + $nop = "#".$this->getClientID(); + $writer->addAttribute('href', $nop); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } /** * Returns postback specifications for the button. diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 1c615edc..1c7fe11b 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -113,15 +113,22 @@ abstract class TListControl extends TDataBoundControl if($this->getIsMultiSelect()) $writer->addAttribute('multiple','multiple'); if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) - { - $writer->addAttribute('id',$this->getClientID()); - $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.'.get_class($this),$this->getPostBackOptions()); - } + $this->renderClientControlScript($writer); if(!$this->getEnabled(true) && $this->getEnabled()) $writer->addAttribute('disabled','disabled'); parent::addAttributesToRender($writer); } + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + $writer->addAttribute('id',$this->getClientID()); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } + /** * @return array postback options for JS postback code */ diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 9a523b55..6a5ade4d 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -154,7 +154,7 @@ class TRadioButton extends TCheckBox $page=$this->getPage(); if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) - $page->getClientScript()->registerPostBackControl('Prado.WebUI.TRadioButton',$this->getPostBackOptions()); + $this->renderClientControlScript($writer); if(($accesskey=$this->getAccessKey())!=='') $writer->addAttribute('accesskey',$accesskey); @@ -165,6 +165,15 @@ class TRadioButton extends TCheckBox $writer->renderBeginTag('input'); $writer->renderEndTag(); } + + /** + * Renders the client-script code. + */ + protected function renderClientControlScript($writer) + { + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } } ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index feea6227..b443fa59 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -143,13 +143,20 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); if($isEnabled && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) - { - $writer->addAttribute('id',$this->getClientID()); - $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TTextBox',$this->getPostBackOptions()); - } + $this->renderClientControlScript($writer); parent::addAttributesToRender($writer); } + /** + * Renders the javascript for textbox. + */ + protected function renderClientControlScript($writer) + { + $writer->addAttribute('id',$this->getClientID()); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions()); + } + /** * Gets the post back options for this textbox. * @return array -- cgit v1.2.3