summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/ActiveControls')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveButton.php28
-rw-r--r--framework/Web/UI/ActiveControls/TActiveTextBox.php18
-rw-r--r--framework/Web/UI/ActiveControls/TBaseActiveControl.php47
3 files changed, 58 insertions, 35 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php
index 3343d7fe..84db60fc 100644
--- a/framework/Web/UI/ActiveControls/TActiveButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveButton.php
@@ -15,7 +15,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
}
-
+
/**
* @return TBaseActiveCallbackControl base callback options.
*/
@@ -23,7 +23,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler
{
return $this->getAdapter()->getActiveControl();
}
-
+
/**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface. If {@link getCausesValidation
@@ -32,7 +32,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler
* 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);
@@ -45,7 +45,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler
* 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);
@@ -58,22 +58,32 @@ class TActiveButton extends TButton implements ICallbackEventHandler
{
parent::setText($value);
if($this->getActiveControl()->canUpdateClientSide())
- $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
}
-
+
/**
* Renders the callback control javascript statement.
*/
protected function renderClientControlScript($writer)
{
}
-
+
protected function addAttributesToRender($writer)
{
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript($this->getPostBackOptions());
+ $this->getActiveControl()->registerCallbackClientScript($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
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveButton';
}
-}
+}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
index fba36a14..91adf8c7 100644
--- a/framework/Web/UI/ActiveControls/TActiveTextBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -15,12 +15,12 @@ class TActiveTextBox extends TTextBox
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
}
-
+
public function getActiveControl()
{
return $this->getAdapter()->getActiveControl();
}
-
+
/**
* Client-side Text property can only be updated after the OnLoad stage.
* @param string text content for the textbox
@@ -29,8 +29,18 @@ class TActiveTextBox extends TTextBox
{
parent::setText($value);
if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
- $this->getPage()->getCallbackClient()->setValue($this, $value);
- }
+ $this->getPage()->getCallbackClient()->setValue($this, $value);
+ }
+
+ /**
+ * 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';
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
index c5a62ade..d2f1ef57 100644
--- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php
+++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
@@ -12,30 +12,30 @@ class TBaseActiveControl extends TComponent
$this->_control = $control;
$this->_options = new TMap;
}
-
+
protected function setOption($name,$value,$default=null)
{
$value = is_null($value) ? $default : $value;
if(!is_null($value))
$this->_options->add($name,$value);
}
-
+
protected function getOption($name,$default=null)
{
$item = $this->_options->itemAt($name);
return is_null($item) ? $default : $item;
}
-
+
protected function getPage()
{
return $this->_control->getPage();
}
-
+
protected function getControl()
{
return $this->_control;
}
-
+
/**
* @param boolean true to allow fine grain callback updates.
*/
@@ -51,18 +51,18 @@ class TBaseActiveControl extends TComponent
{
return $this->getOption('EnableUpdate', true);
}
-
+
public function canUpdateClientSide()
{
- return $this->getControl()->getIsInitialized()
- && $this->getPage()->getIsCallback()
+ return $this->getControl()->getIsInitialized()
+ && $this->getPage()->getIsCallback()
&& $this->getEnableUpdate();
}
}
class TBaseActiveCallbackControl extends TBaseActiveControl
-{
+{
/**
* Callback client-side options can be set by setting the properties of
* the ClientSide property. E.g. <com:TCallback ClientSide.OnSuccess="..." />
@@ -79,13 +79,13 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
}
return $client;
}
-
+
/**
* @return TCallbackClientSideOptions callback client-side options.
*/
protected function createClientSide()
{
- if(($id=$this->getCallbackOptions())!==''
+ if(($id=$this->getCallbackOptions())!==''
&& ($control=$this->getControl()->findControl($id))!==null)
{
if($control instanceof TCallbackOptions)
@@ -103,9 +103,9 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
*/
public function setCallbackOptions($value)
{
- $this->setOption('CallbackOptions', $value, '');
+ $this->setOption('CallbackOptions', $value, '');
}
-
+
/**
* @return string ID of a TCallbackOptions control from which ClientSide
* options are cloned.
@@ -131,8 +131,8 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
public function setCausesValidation($value)
{
$this->setOption('CausesValidation',TPropertyValue::ensureBoolean($value),true);
- }
-
+ }
+
/**
* @return string the group of validators which the button causes validation
* upon callback
@@ -164,8 +164,8 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
}
else
return false;
- }
-
+ }
+
/**
* @return array list of callback javascript options.
*/
@@ -177,15 +177,18 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
$options['ValidationGroup']=$this->getValidationGroup();
return $options;
}
-
+
public function registerCallbackClientScript($options=null)
{
- $cs = $this->getPage()->getClientScript();
+ $cs = $this->getPage()->getClientScript();
if(is_array($options))
$options = array_merge($this->getClientSideOptions(),$options);
else
- $options = $this->getClientSideOptions();
- $cs->registerCallbackControl(get_class($this->getControl()), $options);
+ $options = $this->getClientSideOptions();
+ // TODO (xue):
+ // We need explicitly specify what js class is to be used
+ // to avoid problem that may occur in extended child class
+ $cs->registerCallbackControl('Prado.WebUI.'.get_class($this->getControl()), $options);
}
/**
@@ -197,7 +200,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
*/
public function getJavascript()
{
- $client = $this->getPage()->getClientScript();
+ $client = $this->getPage()->getClientScript();
return $client->getCallbackReference($this->getControl(),$this->getClientSideOptions());
}
}