summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorwei <>2006-05-06 02:26:20 +0000
committerwei <>2006-05-06 02:26:20 +0000
commita7f6c6640ac9295eec3ae2edbb2250179eb85e33 (patch)
tree8a3879c747dfc3bcd5d65f334341ea7c81ced268 /framework/Web/UI
parent46155621cbf97191fca495cbd09a2eedd82afa82 (diff)
Adding TActiveButton and TActiveTextBox
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveButton.php141
-rw-r--r--framework/Web/UI/ActiveControls/TActiveControlAdapter.php4
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLabel.php6
-rw-r--r--framework/Web/UI/ActiveControls/TActivePageAdapter.php1
-rw-r--r--framework/Web/UI/ActiveControls/TActiveTextBox.php139
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php10
-rw-r--r--framework/Web/UI/TClientScriptManager.php21
-rw-r--r--framework/Web/UI/TControl.php8
-rw-r--r--framework/Web/UI/WebControls/TBulletedList.php11
-rw-r--r--framework/Web/UI/WebControls/TButton.php23
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php11
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php20
-rw-r--r--framework/Web/UI/WebControls/TImageMap.php11
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php19
-rw-r--r--framework/Web/UI/WebControls/TListControl.php15
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php11
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php15
17 files changed, 421 insertions, 45 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php
new file mode 100644
index 00000000..db4fa85d
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveButton.php
@@ -0,0 +1,141 @@
+<?php
+/*
+ * Created on 5/05/2006
+ */
+
+class TActiveButton extends TButton implements ICallbackEventHandler
+{
+ /**
+ * @var TCallbackClientSideOptions client-side options.
+ */
+ private $_clientSide;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @param boolean true to allow fine grain callback updates.
+ */
+ public function setAllowCallbackUpdate($value)
+ {
+ $this->setViewState('CallbackUpdate', TPropertyValue::ensureBoolean($value), true);
+ }
+
+ /**
+ * @return true to allow fine grain callback updates.
+ */
+ public function getAllowCallbackUpdate()
+ {
+ return $this->getViewState('CallbackUpdate', true);
+ }
+
+ /**
+ * @return true if can update changes on the client-side during callback.
+ */
+ protected function canUpdateClientSide()
+ {
+ return $this->getIsInitialized() && $this->getAllowCallbackUpdate();
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface. If {@link getCausesValidation
+ * CausesValidation} is true, it will invoke the page's {@link TPage::
+ * validate validate} method first. It will raise {@link onCallback
+ * OnCallback} event and then the {@link onClick OnClick} event. This method
+ * is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->raisePostBackEvent($param);
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * @param string caption of the button
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
+ }
+
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallback ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSideOptions} for details on the properties of
+ * ClientSide.
+ * @return TCallbackClientSideOptions client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if(is_null($this->_clientSide))
+ $this->_clientSide = $this->createClientSideOptions();
+ return $this->_clientSide;
+ }
+
+ /**
+ * @return TCallbackClientSideOptions callback client-side options.
+ */
+ protected function createClientSideOptions()
+ {
+ return new TCallbackClientSideOptions;
+ }
+
+ /**
+ * Renders the callback control javascript statement.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerCallbackControl(get_class($this),$this->getCallbackOptions());
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getCallbackOptions()
+ {
+ return array_merge($this->getPostBackOptions(),
+ $this->getClientSide()->getOptions()->toArray());
+ }
+
+ /**
+ * Returns the javascript statement to invoke a callback request for this
+ * control. Additional options for callback can be set via subproperties of
+ * {@link getClientSide ClientSide} property. E.g. ClientSide.OnSuccess="..."
+ * @param TControl callback handler control, use current object if null.
+ * @return string javascript statement to invoke a callback.
+ */
+ public function getCallbackReference($control=null)
+ {
+ $client = $this->getPage()->getClientScript();
+ $object = is_null($control) ? $this : $control;
+ return $client->getCallbackReference($object, $this->getPostBackOptions());
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 6b410edd..2409d9fe 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -15,13 +15,13 @@ class TActiveControlAdapter extends TControlAdapter
if(!self::$_renderedPosts)
{
$options = TJavascript::encode($this->getPage()->getPostDataLoaders(),false);
- $script = "Prado.CallbackRequest.PostDataLoaders.concat({$options});";
+ $script = "Prado.CallbackRequest.PostDataLoaders = {$options};";
$this->getPage()->getClientScript()->registerEndScript(get_class($this), $script);
self::$_renderedPosts = true;
}
parent::render($writer);
if($this->getPage()->getIsCallback())
$this->getPage()->getCallbackClient()->replace($this->getControl(), $writer);
- }
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveLabel.php b/framework/Web/UI/ActiveControls/TActiveLabel.php
index 7e5a8084..13a88b4f 100644
--- a/framework/Web/UI/ActiveControls/TActiveLabel.php
+++ b/framework/Web/UI/ActiveControls/TActiveLabel.php
@@ -58,7 +58,9 @@ class TActiveLabel extends TLabel
*/
protected function canUpdateClientSide()
{
- return $this->getIsInitialized() && $this->getAllowCallbackUpdate();
+ return $this->getIsInitialized()
+ && $this->getPage()->getIsCallback()
+ && $this->getAllowCallbackUpdate();
}
/**
@@ -69,9 +71,7 @@ class TActiveLabel extends TLabel
{
parent::setText($value);
if($this->canUpdateClientSide())
- {
$this->getPage()->getCallbackClient()->update($this, $value);
- }
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index 67720afd..11c3303e 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -76,7 +76,6 @@ class TActivePageAdapter extends TControlAdapter
{
Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
$this->renderResponse($writer);
- //$this->getResponse()->flush();
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
new file mode 100644
index 00000000..ad28b291
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -0,0 +1,139 @@
+<?php
+/*
+ * Created on 6/05/2006
+ */
+
+class TActiveTextBox extends TTextBox implements ICallbackEventHandler
+{
+ /**
+ * @var TCallbackClientSideOptions client-side options.
+ */
+ private $_clientSide;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @param boolean true to allow fine grain callback updates.
+ */
+ public function setAllowCallbackUpdate($value)
+ {
+ $this->setViewState('CallbackUpdate', TPropertyValue::ensureBoolean($value), true);
+ }
+
+ /**
+ * @return true to allow fine grain callback updates.
+ */
+ public function getAllowCallbackUpdate()
+ {
+ return $this->getViewState('CallbackUpdate', true);
+ }
+
+ /**
+ * @return true if can update changes on the client-side during callback.
+ */
+ protected function canUpdateClientSide()
+ {
+ return $this->getIsInitialized()
+ && $this->getPage()->getIsCallback()
+ && $this->getAllowCallbackUpdate();
+ }
+
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallback ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSideOptions} for details on the properties of
+ * ClientSide.
+ * @return TCallbackClientSideOptions client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if(is_null($this->_clientSide))
+ $this->_clientSide = $this->createClientSideOptions();
+ return $this->_clientSide;
+ }
+
+ /**
+ * @return TCallbackClientSideOptions callback client-side options.
+ */
+ protected function createClientSideOptions()
+ {
+ return new TCallbackClientSideOptions;
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface. It class raisePostDataChangedEvent
+ * first then raises {@link onCallback OnCallback} event. This method is
+ * mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->raisePostDataChangedEvent();
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Client-side Text property can only be updated after the OnLoad stage.
+ * @param string text content for the textbox
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->canUpdateClientSide() && $this->getHasLoadedPostData())
+ $this->getPage()->getCallbackClient()->setValue($this, $value);
+ }
+
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerCallbackControl(get_class($this),$this->getCallbackOptions());
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getCallbackOptions()
+ {
+ return array_merge($this->getPostBackOptions(),
+ $this->getClientSide()->getOptions()->toArray());
+ }
+
+ /**
+ * Returns the javascript statement to invoke a callback request for this
+ * control. Additional options for callback can be set via subproperties of
+ * {@link getClientSide ClientSide} property. E.g. ClientSide.OnSuccess="..."
+ * @param TControl callback handler control, use current object if null.
+ * @return string javascript statement to invoke a callback.
+ */
+ public function getCallbackReference($control=null)
+ {
+ $client = $this->getPage()->getClientScript();
+ $object = is_null($control) ? $this : $control;
+ return $client->getCallbackReference($object, $this->getPostBackOptions());
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
index 8c6732e3..3eadcd29 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
@@ -221,11 +221,12 @@ class TCallbackClientSideOptions extends TClientSideOptions
/**
* @return boolean true if the callback request has priority and will abort
* existing prioritized request in order to send immediately. It does not
- * affect callbacks that are not prioritized.
+ * affect callbacks that are not prioritized. Default is true.
*/
public function getHasPriority()
{
- return $this->getOption('HasPriority');
+ $option = $this->getOption('HasPriority');
+ return is_null($option) ? true : $option;
}
/**
@@ -257,11 +258,12 @@ class TCallbackClientSideOptions extends TClientSideOptions
/**
* @return boolean client-side viewstate will be updated on callback
- * response if true.
+ * response if true. Default is true.
*/
public function getEnablePageStateUpdate()
{
- return $this->getOption('EnablePageStateUpdate');
+ $option = $this->getOption('EnablePageStateUpdate');
+ return is_null($option) ? true : $option;
}
}
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index 20612ce2..cad317ef 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -177,16 +177,33 @@ class TClientScriptManager extends TApplicationComponent
}
/**
+ * Registers callback javascript for a control.
+ * @param string javascript class responsible for the control being registered for callback
+ * @param array callback options
+ */
+ public function registerCallbackControl($class, $options)
+ {
+ $optionString=TJavaScript::encode($options);
+ $code="new Prado.WebUI.{$class}({$optionString});";
+ $this->_endScripts[sprintf('%08X', crc32($code))]=$code;
+ $this->registerPradoScriptInternal('ajax');
+
+ $params=func_get_args();
+ foreach($this->_page->getCachingStack() as $item)
+ $item->registerAction('Page.ClientScript','registerCallbackControl',$params);
+ }
+
+ /**
* Registers postback javascript for a control.
* @param string javascript class responsible for the control being registered for postback
* @param array postback options
*/
- public function registerPostBackControl($jsClass,$options)
+ public function registerPostBackControl($class,$options)
{
if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null)
$options['FormID']=$form->getClientID();
$optionString=TJavaScript::encode($options);
- $code="new $jsClass($optionString);";
+ $code="new Prado.WebUI.{$class}({$optionString});";
$this->_endScripts[sprintf('%08X', crc32($code))]=$code;
$this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET]='';
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 3bb893e2..7121e5ed 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -1005,6 +1005,14 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
{
return $this->getControlStage() >= self::CS_CHILD_INITIALIZED;
}
+
+ /**
+ * @return boolean true if the control has loaded post data.
+ */
+ public function getHasLoadedPostData()
+ {
+ return $this->getControlStage() >= self::CS_LOADED;
+ }
/**
* Returns the named registered object.
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,14 +72,8 @@ 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');
@@ -87,6 +81,19 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
}
/**
+ * 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
*/
protected function canCauseValidation()
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);
@@ -364,6 +364,15 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
+ * 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,19 +88,25 @@ 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
*/
protected function canCauseValidation()
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,16 +113,23 @@ 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
*/
protected function getPostBackOptions()
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,14 +143,21 @@ 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
*/