From 4f968c045e0d09ab3e4f659743effb5305a963ce Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 30 Mar 2007 05:04:30 +0000 Subject: Fixed #507 and update other active controls. --- .../Web/UI/ActiveControls/TActiveCheckBox.php | 16 ++++++++++++- .../Web/UI/ActiveControls/TActiveCheckBoxList.php | 13 ++-------- .../UI/ActiveControls/TActiveCustomValidator.php | 13 +++++----- framework/Web/UI/ActiveControls/TActiveListBox.php | 20 ++++++++++++++++ .../Web/UI/ActiveControls/TActiveRadioButton.php | 13 +++++++++- .../UI/ActiveControls/TActiveRadioButtonList.php | 14 ++--------- framework/Web/UI/ActiveControls/TActiveTextBox.php | 28 +++++++++++++++------- framework/Web/UI/ActiveControls/TAutoComplete.php | 17 ++----------- .../Web/UI/ActiveControls/TInPlaceTextBox.php | 24 ------------------- framework/Web/UI/WebControls/TBaseValidator.php | 9 ++++--- 10 files changed, 83 insertions(+), 84 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBox.php b/framework/Web/UI/ActiveControls/TActiveCheckBox.php index 2f60d9fb..777ff6ad 100644 --- a/framework/Web/UI/ActiveControls/TActiveCheckBox.php +++ b/framework/Web/UI/ActiveControls/TActiveCheckBox.php @@ -111,10 +111,24 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv } /** - * Registers the javascript code for initializing the active control. + * Override parent implementation, no javascript is rendered here instead + * the javascript required for active control is registered in {@link addAttributesToRender}. */ protected function renderClientControlScript($writer) { + } + + /** + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. + * @param THtmlWriter the writer for the rendering purpose + * @param string checkbox id + * @param string onclick js + */ + protected function renderInputTag($writer,$clientID,$onclick) + { + parent::renderInputTag($writer,$clientID,$onclick); + $writer->addAttribute('id',$this->getClientID()); $this->getActiveControl()->registerCallbackClientScript( $this->getClientClassName(), $this->getPostBackOptions()); } diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php index 09ad9236..0b86f4bf 100644 --- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php +++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php @@ -65,20 +65,11 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall } /** - * @return string javascript client-side control class name. - */ - protected function getClientClassName() - { - return 'Prado.WebUI.TActiveCheckBoxList'; - } - - /** - * Registers the javascript code for initializing the active control. + * Override parent implementation, no javascript is rendered here instead + * the javascript required for active control is registered in {@link addAttributesToRender}. */ protected function renderClientControlScript($writer) { - $this->getActiveControl()->registerCallbackClientScript( - $this->getClientClassName(), $this->getPostBackOptions()); } /** diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php index 1668b54f..ad0dd51e 100644 --- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php +++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php @@ -128,7 +128,7 @@ class TActiveCustomValidator extends TCustomValidator * Sets the text for the error message. Updates client-side erorr message. * @param string the error message */ - public function setErrorMessage($value) + public function setErrorMessage($value) { parent::setErrorMessage($value); if($this->getActiveControl()->canUpdateClientSide()) @@ -139,13 +139,14 @@ class TActiveCustomValidator extends TCustomValidator } } - /** - * Register the javascript for the active custom validator. + /** + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. */ - protected function registerClientScriptValidator() + protected function addAttributesToRender($writer) { - $this->getActiveControl()->registerCallbackClientScript( - $this->getClientClassName(), $this->getClientScriptOptions()); + parent::addAttributesToRender($writer); + TBaseValidator::registerClientScriptValidator(); } /** diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php index 97b28ac7..cafb3a29 100644 --- a/framework/Web/UI/ActiveControls/TActiveListBox.php +++ b/framework/Web/UI/ActiveControls/TActiveListBox.php @@ -132,6 +132,26 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH if($multiple) $this->getPage()->registerPostDataLoader($multi_id); } + + /** + * Override parent implementation, no javascript is rendered here instead + * the javascript required for active control is registered in {@link addAttributesToRender}. + */ + protected function renderClientControlScript($writer) + { + } + + /** + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. + */ + protected function addAttributesToRender($writer) + { + parent::addAttributesToRender($writer); + $writer->addAttribute('id',$this->getClientID()); + $this->getActiveControl()->registerCallbackClientScript( + $this->getClientClassName(), $this->getPostBackOptions()); + } } ?> \ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php index 425cf1c7..16a91688 100644 --- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php +++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php @@ -121,10 +121,21 @@ class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallba } /** - * Registers the javascript code for initializing the active control. + * Override parent implementation, no javascript is rendered here instead + * the javascript required for active control is registered in {@link addAttributesToRender}. */ protected function renderClientControlScript($writer) { + } + + /** + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. + */ + protected function renderInputTag($writer,$clientID,$onclick) + { + parent::renderInputTag($writer,$clientID,$onclick); + $writer->addAttribute('id',$this->getClientID()); $this->getActiveControl()->registerCallbackClientScript( $this->getClientClassName(), $this->getPostBackOptions()); } diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php index 6e3fef6f..52a4b036 100644 --- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php +++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php @@ -60,20 +60,11 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, } /** - * @return string javascript client-side control class name. - */ - protected function getClientClassName() - { - return 'Prado.WebUI.TActiveRadioButtonList'; - } - - /** - * Registers the javascript code for initializing the active control. + * Override parent implementation, no javascript is rendered here instead + * the javascript required for active control is registered in {@link addAttributesToRender}. */ protected function renderClientControlScript($writer) { - $this->getActiveControl()->registerCallbackClientScript( - $this->getClientClassName(), $this->getPostBackOptions()); } /** @@ -95,7 +86,6 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, */ public function raiseCallbackEvent($param) { - var_dump($_POST); $this->onCallback($param); } diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php index 8e6c86dd..c7ee916d 100644 --- a/framework/Web/UI/ActiveControls/TActiveTextBox.php +++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php @@ -93,23 +93,33 @@ class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveC } /** - * Renders the javascript for textbox. + * Gets the name of the javascript class responsible for performing postback for this control. + * This method overrides the parent implementation. + * @return string the javascript class name + */ + protected function getClientClassName() + { + return 'Prado.WebUI.TActiveTextBox'; + } + + /** + * Override parent implementation, no javascript is rendered here instead + * the javascript required for active control is registered in {@link addAttributesToRender}. */ protected function renderClientControlScript($writer) { - $writer->addAttribute('id',$this->getClientID()); - $this->getActiveControl()->registerCallbackClientScript( - $this->getClientClassName(), $this->getPostBackOptions()); } /** - * Gets the name of the javascript class responsible for performing postback for this control. - * This method overrides the parent implementation. - * @return string the javascript class name + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. */ - protected function getClientClassName() + protected function addAttributesToRender($writer) { - return 'Prado.WebUI.TActiveTextBox'; + parent::addAttributesToRender($writer); + $writer->addAttribute('id',$this->getClientID()); + $this->getActiveControl()->registerCallbackClientScript( + $this->getClientClassName(), $this->getPostBackOptions()); } } diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index 07fa652b..f94a826f 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -270,7 +270,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer /** * @return array list of callback options. */ - protected function getAutoCompleteOptions() + protected function getPostBackOptions() { $this->getActiveControl()->getClientSide()->setEnablePageStateUpdate(false); $options = array(); @@ -282,7 +282,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer } if($this->getAutoPostBack()) { - $options = array_merge($options,$this->getPostBackOptions()); + $options = array_merge($options,parent::getPostBackOptions()); $options['AutoPostBack'] = true; } $options['ResultPanel'] = $this->getResultPanel()->getClientID(); @@ -299,19 +299,6 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer { } - /** - * Ensure that the ID attribute is rendered and registers the javascript code - * for initializing the active control. - */ - - public function addAttributesToRender($writer) - { - parent::addAttributesToRender($writer); - $writer->addAttribute('id',$this->getClientID()); - $this->getActiveControl()->registerCallbackClientScript( - $this->getClientClassName(), $this->getAutoCompleteOptions()); - } - /** * @return string corresponding javascript class name for this TActiveButton. */ diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php index 16ffafb7..88db2d8f 100644 --- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php +++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php @@ -149,21 +149,6 @@ class TInPlaceTextBox extends TActiveTextBox return 'span'; } - /** - * Adds attributes to renderer. - * @param THtmlWriter the renderer - * @throws TInvalidDataValueException if associated control cannot be found using the ID - */ - protected function addAttributesToRender($writer) - { - TWebControl::addAttributesToRender($writer); - $page=$this->getPage(); - $page->ensureRenderInForm($this); - $writer->addAttribute('id', $this->getLabelClientID()); - if(!$this->getReadOnly()) - $this->renderClientControlScript($writer); - } - /** * Renders the body content of the label. * @param THtmlWriter the writer for rendering @@ -240,15 +225,6 @@ class TInPlaceTextBox extends TActiveTextBox $this->raiseEvent('OnLoadingText',$this,$param); } - /** - * Registers the javascript code for initializing the active control. - */ - protected function renderClientControlScript($writer) - { - $this->getActiveControl()->registerCallbackClientScript( - $this->getClientClassName(), $this->getPostBackOptions()); - } - /** * @return string corresponding javascript class name for this TInPlaceTextBox */ diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 99a81375..a755d605 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -172,8 +172,7 @@ abstract class TBaseValidator extends TLabel implements IValidator if($control instanceof TDatePicker) $options['DateFormat'] = $control->getDateFormat(); - if(!is_null($this->_clientSide)) - $options = array_merge($options,$this->_clientSide->getOptions()->toArray()); + $options = array_merge($options,$this->getClientSide()->getOptions()->toArray()); return $options; } @@ -242,7 +241,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $scripts->registerPradoScript('validator'); $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); } - if($this->getEnableClientScript()) + if($this->getEnableClientScript() & $this->getEnabled(true)) $this->registerClientScriptValidator(); $this->updateControlCssClass(); } @@ -272,9 +271,9 @@ abstract class TBaseValidator extends TLabel implements IValidator */ protected function registerClientScriptValidator() { - if($this->getEnabled(true)) + $key = 'prado:'.$this->getClientID(); + if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) { - $key = 'prado:'.$this->getClientID(); $options = TJavaScript::encode($this->getClientScriptOptions()); $script = 'new '.$this->getClientClassName().'('.$options.');'; $this->getPage()->getClientScript()->registerEndScript($key, $script); -- cgit v1.2.3