From 47d05516b1d1c465217c59732bf8442ab0cfd497 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 5 May 2006 06:58:04 +0000 Subject: Added prioritize callback and enabled viewstate update on callback return. --- .../ActiveControls/TCallbackClientSideOptions.php | 114 ++++++++++++--------- 1 file changed, 65 insertions(+), 49 deletions(-) (limited to 'framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php') diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php index 6a4731f7..c0a817f0 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php @@ -1,37 +1,4 @@ _options = Prado::createComponent('System.Collections.TMap'); - } - - protected function setFunction($name, $code) - { - $this->_options->add($name, $this->ensureFunction($code)); - } - - protected function getOption($name) - { - return $this->_options->itemAt($name); - } - - public function getOptions() - { - return $this->_options; - } - - protected function ensureFunction($javascript) - { - return $javascript; - } -} /** * TCallbackClientSideOptions class. @@ -54,6 +21,15 @@ class TClientSideOptions extends TComponent * - onException raised when callback request fails due to * request/response errors. * + * - PostInputs true to collect the form inputs and post them during + * callback, default is true. + * - RequestTimeOut The request timeout in milliseconds. + * - HasPriority true to ensure that the callback request will be sent + * immediately and will abort existing prioritized requests. It does not affect + * callbacks that are not prioritized. + * - EnablePageStateUpdate enable the callback response to enable the + * viewstate update. This will automatically set HasPrority to true when + * enabled. */ class TCallbackClientSideOptions extends TClientSideOptions { @@ -65,13 +41,7 @@ class TCallbackClientSideOptions extends TClientSideOptions */ protected function ensureFunction($javascript) { - if(TJavascript::isFunction($javascript)) - return $javascript; - else - { - $code = "function(request, result){ {$javascript} }"; - return TJavascript::quoteFunction($code); - } + return "function(request, result){ {$javascript} }"; } /** @@ -200,21 +170,21 @@ class TCallbackClientSideOptions extends TClientSideOptions } /** - * @return boolean true to post the state on callback, default is post the - * state on callback. + * @return boolean true to post the inputs of the form on callback, default + * is post the inputs on callback. */ public function getPostState() { - return $this->getOption('PostState'); + return $this->getOption('PostInputs'); } /** - * @param boolean true to post the state of the form with callback requests. - * Default is to post the state. + * @param boolean true to post the inputs of the form with callback + * requests. Default is to post the inputs. */ public function setPostState($value) { - $this->getOptions()->add('PostState', TPropertyValue::ensureBoolean($value)); + $this->setOption('PostInputs', TPropertyValue::ensureBoolean($value)); } /** @@ -222,7 +192,7 @@ class TCallbackClientSideOptions extends TClientSideOptions */ public function getRequestTimeOut() { - return $this->getOption('TimeOut'); + return $this->getOption('RequestTimeOut'); } /** @@ -230,8 +200,54 @@ class TCallbackClientSideOptions extends TClientSideOptions */ public function setRequestTimeOut($value) { - $this->getOptions()->add('TimeOut', TPropertyValue::ensureInteger($value)); + $this->setOption('RequestTimeOut', TPropertyValue::ensureInteger($value)); + } + + /** + * @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. + */ + public function getHasPriority() + { + return $this->getOption('HasPriority'); + } + + /** + * @param boolean true to ensure that the callback request will be sent + * immediately and will abort existing prioritized requests. It does not + * affect callbacks that are not prioritized. + */ + public function setHasPriority($value) + { + $hasPriority = TPropertyValue::ensureBoolean($value); + $this->setOption('HasPriority', $hasPriority); + if(!$hasPriority) + $this->setEnablePageStateUpdate(false); + } + + /** + * Set to true to enable the callback response to enable the viewstate + * update. This will automatically set HasPrority to true. + * @param boolean true enables the callback response to update the + * viewstate. + */ + public function setEnablePageStateUpdate($value) + { + $enabled = TPropertyValue::ensureBoolean($value); + $this->setOption('EnablePageStateUpdate', $enabled); + if($enabled) + $this->setHasPriority(true); + } + + /** + * @return boolean client-side viewstate will be updated on callback + * response if true. + */ + public function getEnablePageStateUpdate() + { + return $this->getOption('EnablePageStateUpdate'); } } -?> +?> \ No newline at end of file -- cgit v1.2.3