diff options
author | wei <> | 2006-10-01 03:09:18 +0000 |
---|---|---|
committer | wei <> | 2006-10-01 03:09:18 +0000 |
commit | 36f2ce766bde98c11d57b889fd9e1a7f8dff6010 (patch) | |
tree | 87c33c9e4447e20159932824b4de6167da495d49 /framework/Web/UI | |
parent | 1c32172efb18e8d08ea483e2460813670ebfe1a5 (diff) |
Fixed #350 and #148, Add TActiveRatingList, should remove TRatingList from WebControls.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveCheckBoxList.php | 21 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveControlAdapter.php | 8 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveRadioButtonList.php | 21 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveRatingList.php | 240 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TButton.php | 18 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TCheckBox.php | 24 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TCheckBoxList.php | 43 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TImageButton.php | 31 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TLinkButton.php | 18 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 22 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRadioButton.php | 23 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRadioButtonList.php | 20 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TTextBox.php | 23 |
13 files changed, 466 insertions, 46 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php index f70a6407..b18d0d0d 100644 --- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php +++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php @@ -43,9 +43,9 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall */ public function __construct() { - parent::__construct(); $this->setAdapter(new TActiveListControlAdapter($this)); $this->setAutoPostBack(true); + parent::__construct(); } /** @@ -57,13 +57,20 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall } /** - * No client class for this control. - * This method overrides the parent implementation. - * @return null no javascript class name. + * @return string javascript client-side control class name. */ protected function getClientClassName() { - return null; + return 'Prado.WebUI.TActiveCheckBoxList'; + } + + /** + * Registers the javascript code for initializing the active control. + */ + protected function renderClientControlScript($writer) + { + $this->getActiveControl()->registerCallbackClientScript( + $this->getClientClassName(), $this->getPostBackOptions()); } /** @@ -72,7 +79,9 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall */ protected function createRepeatedControl() { - return new TActiveCheckBox; + $control = new TActiveCheckBox; + $control->getAdapter()->setBaseActiveControl($this->getActiveControl()); + return $control; } /** diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php index 58b65486..8e637719 100644 --- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php @@ -105,6 +105,14 @@ class TActiveControlAdapter extends TControlAdapter }
/**
+ * @param TBaseActiveControl change base active control
+ */
+ public function setBaseActiveControl($control)
+ {
+ $this->_baseActiveControl=$control;
+ }
+
+ /**
* @return TBaseActiveControl Common active control options.
*/
public function getBaseActiveControl()
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php index 3eb57ec7..f971228f 100644 --- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php +++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php @@ -38,9 +38,9 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, */ public function __construct() { - parent::__construct(); $this->setAdapter(new TActiveListControlAdapter($this)); $this->setAutoPostBack(true); + parent::__construct(); } /** @@ -52,13 +52,20 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, } /** - * No client class for this control. - * This method overrides the parent implementation. - * @return null no javascript class name. + * @return string javascript client-side control class name. */ protected function getClientClassName() { - return null; + return 'Prado.WebUI.TActiveRadioButtonList'; + } + + /** + * Registers the javascript code for initializing the active control. + */ + protected function renderClientControlScript($writer) + { + $this->getActiveControl()->registerCallbackClientScript( + $this->getClientClassName(), $this->getPostBackOptions()); } /** @@ -67,7 +74,9 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, */ protected function createRepeatedControl() { - return new TActiveRadioButton; + $control = new TActiveRadioButton; + $control->getAdapter()->setBaseActiveControl($this->getActiveControl()); + return $control; } /** diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php new file mode 100644 index 00000000..1ce49a0c --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php @@ -0,0 +1,240 @@ +<?php
+
+class TActiveRatingList extends TActiveRadioButtonList
+{
+ private $_ratingImages = array();
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setRepeatDirection(TRepeatDirection::Horizontal);
+ }
+
+ /**
+ * @return boolean whether the items in the column can be edited. Defaults to false.
+ */
+ public function getReadOnly()
+ {
+ return $this->getViewState('ReadOnly',false);
+ }
+
+ public function setRepeatLayout($value)
+ {
+ if($value!==TRepeatLayout::Table)
+ throw new TInvalidDataValueException('ratinglist_table_layout_only');
+ else
+ parent::setRepeatLayout($value);
+ }
+
+ /**
+ * @param boolean whether the items in the column can be edited
+ */
+ public function setReadOnly($value)
+ {
+ $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false);
+ }
+
+ public function getRating()
+ {
+ return $this->getViewState('Rating',0);
+ }
+
+ public function setRating($value)
+ {
+ $this->setViewState('Rating', TPropertyValue::ensureFloat($value),0);
+ }
+
+ public function setSelectedIndex($value)
+ {
+ $canUpdate = $this->getActiveControl()->getEnableUpdate();
+ $this->getActiveControl()->setEnableUpdate(false);
+ parent::setSelectedIndex($value);
+ $this->getActiveControl()->setEnableUpdate($canUpdate);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->callClientFunction('setRating',$value);
+ }
+
+ protected function callClientFunction($func,$value)
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $code = $this->getClientClassName().'.'.$func;
+ $client->callClientFunction($code,array($this,$value));
+ }
+
+ /**
+ * @return string caption text.
+ */
+ public function getCaptionID()
+ {
+ return $this->getViewState('CaptionID', '');
+ }
+
+ /**
+ * @param string caption text
+ */
+ public function setCaptionID($value)
+ {
+ $this->setViewState('CaptionID', $value, '');
+ }
+
+ public function setEnabled($value)
+ {
+ parent::setEnabled($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->callClientFunction('setEnabled',$value);
+ }
+
+ /**
+ * @param string set the rating style
+ */
+ public function setRatingStyle($value)
+ {
+ $this->setViewState('RatingStyle', $value, 'default');
+ }
+
+ /**
+ * @return TRatingListStyle current rating style
+ */
+ public function getRatingStyle()
+ {
+ return $this->getViewState('RatingStyle', 'default');
+ }
+
+ public function setHalfRatingLimit($value)
+ {
+ $this->setViewState('HalfRating',
+ TPropertyValue::ensureArray($value), array(0.3, 0.7));
+ }
+
+ public function getHalfRatingLimit()
+ {
+ return $this->getViewState('HalfRating', array(0.3, 0.7));
+ }
+
+ protected function getRatingStyleCssClass()
+ {
+ return 'TRatingList_'.$this->getRatingStyle();
+ }
+
+ protected function getPostBackOptions()
+ {
+ $options = parent::getPostBackOptions();
+ $options['Style'] = $this->getRatingStyleCssClass();
+ $options['CaptionID'] = $this->getCaptionControl();
+ $options['SelectedIndex'] = $this->getSelectedIndex();
+ return $options;
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ if($this->getReadOnly()===false)
+ parent::renderClientControlScript($writer);
+ }
+
+ protected function getCaptionControl()
+ {
+ if(($id=$this->getCaptionID())!=='')
+ {
+ if($control=$this->getParent()->findControl($id))
+ {
+ if($control->getVisible(true))
+ return $control->getClientID();
+ }
+ else
+ return $id;
+ }
+ return '';
+ }
+
+ protected function publishRatingListStyle($style)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $stylesheet = 'System.Web.Javascripts.ratings.'.$style;
+ if(($cssFile=Prado::getPathOfNamespace($stylesheet,'.css'))===null)
+ throw new TConfigurationException('ratinglist_stylesheet_not_found',$style);
+ $url = $this->publishFilePath($cssFile);
+ if(!$cs->isStyleSheetFileRegistered($style))
+ $cs->registerStyleSheetFile($style, $url);
+ return $url;
+ }
+
+ protected function publishRatingListImages($style, $fileExt='.png')
+ {
+ $images['blank'] = "System.Web.Javascripts.ratings.{$style}_blank";
+ $images['selected'] = "System.Web.Javascripts.ratings.{$style}_selected";
+ $images['half'] = "System.Web.Javascripts.ratings.{$style}_half";
+ $images['combined'] = "System.Web.Javascripts.ratings.{$style}_combined";
+ $files = array();
+ foreach($images as $type => $image)
+ {
+ if(($file=Prado::getPathOfNamespace($image, $fileExt))===null)
+ throw TConfigurationException('ratinglist_image_not_found',$image);
+ $files[$type] = $this->publishFilePath($file);
+ }
+ return $files;
+ }
+
+ public function render($writer)
+ {
+ if($this->getReadOnly())
+ {
+ $writer->addAttribute('class', $this->getRatingStyleCssClass());
+ $writer->addAttribute('title', $this->getRating());
+ }
+ parent::render($writer);
+ }
+
+ /**
+ * @param THtmlWriter writer
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+
+ $this->publishRatingListStyle($this->getRatingStyle());
+ $this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle());
+ }
+
+ public function renderItem($writer,$repeatInfo,$itemType,$index)
+ {
+ if($this->getReadOnly())
+ $this->renderStaticRating($writer, $repeatInfo, $itemType, $index);
+ else
+ parent::renderItem($writer, $repeatInfo, $itemType, $index);
+ }
+
+ protected function renderStaticRating($writer, $repeatInfo, $itemType, $index)
+ {
+ $image = new TImage;
+ $image->setImageUrl($this->_ratingImages[$this->getRatingImageType($index)]);
+ $image->setAlternateText($this->getRating());
+ $image->render($writer);
+ }
+
+ protected function getRatingImageType($index)
+ {
+ $rating = floatval($this->getRating());
+ $int = intval($rating);
+ $limit = $this->getHalfRatingLimit();
+ if($index < $int || ($rating < $index+1 && $rating > $index+$limit[1]))
+ return 'selected';
+ if($rating >= $index+$limit[0] && $rating <= $index+$limit[1])
+ return 'half';
+ return 'blank';
+ }
+
+ /**
+ * 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.TRatingList';
+ }
+}
+
+?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index 59df8f7c..0b118495 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -58,6 +58,22 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional button specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -72,7 +88,7 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr $writer->addAttribute('value',$this->getText());
if($this->getEnabled(true))
{
- if($this->needPostBackScript())
+ if($this->needPostBackScript() && $this->getEnableClientScript())
$this->renderClientControlScript($writer);
}
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 2b9fd6b7..fefc9331 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -337,6 +337,22 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Renders a label beside the checkbox.
* @param THtmlWriter the writer for the rendering purpose
* @param string checkbox id
@@ -375,8 +391,13 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $writer->addAttribute('disabled','disabled');
$page=$this->getPage();
- if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($this->getEnabled(true)
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -419,7 +440,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $options['EventTarget'] = $this->getUniqueID();
return $options;
}
-
}
/**
diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 89357b55..09b771eb 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -106,16 +106,6 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont }
/**
- * 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.TCheckBoxList';
- }
-
- /**
* @return TTextAlign the alignment of the text caption, defaults to TTextAlign::Right.
*/
public function getTextAlign()
@@ -296,6 +286,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $repeatedControl->setChecked($item->getSelected());
$repeatedControl->setAttribute('value',$item->getValue());
$repeatedControl->setEnabled($this->_isEnabled && $item->getEnabled());
+ $repeatedControl->setEnableClientScript(false);
$repeatedControl->renderControl($writer);
}
@@ -389,6 +380,14 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $this->setAccessKey($accessKey);
$this->setTabIndex($tabIndex);
}
+ //checkbox skipped the client control script in addAttributesToRender
+ if($this->getEnabled(true)
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $this->getPage()->getClientSupportsJavaScript())
+ {
+ $this->renderClientControlScript($writer);
+ }
}
/**
@@ -400,6 +399,30 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont {
return $this->getSelectedValue();
}
+
+ /**
+ * 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.TCheckBoxList';
+ }
+
+ /**
+ * Gets the post back options for this checkbox.
+ * @return array
+ */
+ protected function getPostBackOptions()
+ {
+ $options['ListID'] = $this->getClientID();
+ $options['ValidationGroup'] = $this->getValidationGroup();
+ $options['CausesValidation'] = $this->getCausesValidation();
+ $options['ListName'] = $this->getUniqueID();
+ $options['ItemCount'] = $this->getItemCount();
+ return $options;
+ }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index ad5d7bf0..3e96abdc 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -76,6 +76,22 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional button specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -87,8 +103,12 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven $writer->addAttribute('type','image');
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
- if($this->getEnabled(true))
+ if($this->getEnabled(true)
+ && $this-canCauseValidation()
+ && $this->getEnableClientScript())
+ {
$this->renderClientControlScript($writer);
+ }
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
@@ -99,12 +119,9 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven */
protected function renderClientControlScript($writer)
{
- if($this->canCauseValidation())
- {
- $writer->addAttribute('id',$this->getClientID());
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
- }
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d7586bde..ffa83d02 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -65,6 +65,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional button specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -80,7 +96,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC // may be overwritten in the following
parent::addAttributesToRender($writer);
- if($this->getEnabled(true))
+ if($this->getEnabled(true) && $this->getEnableClientScript())
{
$this->renderLinkButtonHref($writer);
$this->renderClientControlScript($writer);
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 7576154e..056a8548 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -106,6 +106,22 @@ abstract class TListControl extends TDataBoundControl }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attributes to renderer.
* @param THtmlWriter the renderer
*/
@@ -117,8 +133,12 @@ abstract class TListControl extends TDataBoundControl $writer->addAttribute('multiple','multiple');
if($this->getEnabled(true))
{
- if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($this->getAutoPostBack()
+ && $this->getEnableClientScript()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
}
else if($this->getEnabled())
$writer->addAttribute('disabled','disabled');
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index dac194b7..9b6bf794 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -234,6 +234,22 @@ class TRadioButton extends TCheckBox }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Renders a radiobutton input element.
* @param THtmlWriter the writer for the rendering purpose
* @param string checkbox id
@@ -254,8 +270,13 @@ class TRadioButton extends TCheckBox $writer->addAttribute('disabled','disabled');
$page=$this->getPage();
- if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($this->getEnabled(true)
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php index b314b963..97328c73 100644 --- a/framework/Web/UI/WebControls/TRadioButtonList.php +++ b/framework/Web/UI/WebControls/TRadioButtonList.php @@ -53,16 +53,6 @@ class TRadioButtonList extends TCheckBoxList }
/**
- * 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.TRadioButtonList';
- }
-
- /**
* 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
@@ -97,6 +87,16 @@ class TRadioButtonList extends TCheckBoxList {
throw new TNotSupportedException('radiobuttonlist_selectedindices_unsupported');
}
+
+ /**
+ * 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.TRadioButtonList';
+ }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index ad6de40c..588830f0 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -76,6 +76,22 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable }
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This method overrides the parent implementation with additional textbox specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -138,8 +154,13 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable $isEnabled=$this->getEnabled(true);
if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
- if($isEnabled && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($isEnabled
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
parent::addAttributesToRender($writer);
}
|