diff options
Diffstat (limited to 'framework/Web/UI/ActiveControls')
7 files changed, 89 insertions, 69 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php index b95bdd37..77973b2c 100644 --- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php @@ -22,4 +22,4 @@ class TActiveControlAdapter extends TControlAdapter parent::render($writer);
}
}
-?>
+?>
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveLabel.php b/framework/Web/UI/ActiveControls/TActiveLabel.php index d71d8b7a..3216be43 100644 --- a/framework/Web/UI/ActiveControls/TActiveLabel.php +++ b/framework/Web/UI/ActiveControls/TActiveLabel.php @@ -29,7 +29,7 @@ class TActiveLabel extends TLabel /**
* 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, call this constructor.
+ * adapter appropriately by, for example, by calling this constructor.
*/
public function __construct()
{
@@ -44,7 +44,7 @@ class TActiveLabel extends TLabel public function setText($value)
{
parent::setText($value);
- if($this->getPage()->getAllowCallbackUpdate())
+ if($this->getIsInitialized())
{
$this->getPage()->getCallbackClient()->update($this, $value);
}
@@ -59,7 +59,7 @@ class TActiveLabel extends TLabel public function setForControl($value)
{
parent::setForControl($value);
- if($this->getPage()->getAllowCallbackUpdate())
+ if($this->getIsInitialized())
{
$id=$this->findControl($value)->getClientID();
$this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id);
@@ -67,4 +67,4 @@ class TActiveLabel extends TLabel }
}
-?>
+?>
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index db783a12..67720afd 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -25,6 +25,7 @@ class TActivePageAdapter extends TControlAdapter const CALLBACK_DATA_HEADER = 'X-PRADO-DATA';
const CALLBACK_ACTION_HEADER = 'X-PRADO-ACTIONS';
const CALLBACK_ERROR_HEADER = 'X-PRADO-ERROR';
+ const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE';
/**
* @var ICallbackEventHandler callback event handler.
@@ -80,7 +81,7 @@ class TActivePageAdapter extends TControlAdapter /**
* Renders the callback response by adding additional callback data and
- * javascript actions in the header.
+ * javascript actions in the header and page state if required.
*/
protected function renderResponse($writer)
{
@@ -92,7 +93,15 @@ class TActivePageAdapter extends TControlAdapter {
$data = TJavascript::jsonEncode($this->_result->getData());
$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data);
- }
+ }
+ if(($handler = $this->getCallbackEventTarget()) !== null)
+ {
+ if($handler->getClientSide()->getEnablePageStateUpdate())
+ {
+ $pagestate = $this->getPage()->getClientState();
+ $response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate);
+ }
+ }
}
/**
@@ -329,4 +338,4 @@ class TInvalidCallbackRequestException extends TException {
}
-?>
+?>
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php index 9c3234fd..9d2301d8 100644 --- a/framework/Web/UI/ActiveControls/TCallback.php +++ b/framework/Web/UI/ActiveControls/TCallback.php @@ -147,4 +147,4 @@ class TCallback extends TControl implements ICallbackEventHandler }
}
-?>
+?>
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 5f8851db..5d317c8a 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -531,4 +531,4 @@ class TCallbackClientScript extends TApplicationComponent }
}
-?>
+?>
\ No newline at end of file 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 @@ <?php
-/*
- * Created on 1/05/2006
- */
-
-class TClientSideOptions extends TComponent
-{
- private $_options;
-
- public function __construct()
- {
- $this->_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 * - <b>onException</b> raised when callback request fails due to
* request/response errors.
*
+ * - <b>PostInputs</b> true to collect the form inputs and post them during
+ * callback, default is true.
+ * - <b>RequestTimeOut</b> The request timeout in milliseconds.
+ * - <b>HasPriority</b> 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.
+ * - <b>EnablePageStateUpdate</b> 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 diff --git a/framework/Web/UI/ActiveControls/TCallbackResponse.php b/framework/Web/UI/ActiveControls/TCallbackResponse.php index 4a893b9a..024ad6ef 100644 --- a/framework/Web/UI/ActiveControls/TCallbackResponse.php +++ b/framework/Web/UI/ActiveControls/TCallbackResponse.php @@ -1,14 +1,8 @@ <?php
-/*
- * Created on 29/04/2006
- */
-
-// See TActivePageAdapter::renderResponse()
-//TODO: How to render the response, it will contain 3 pieces of data
-// 1) The arbituary data returned to the client-side callback handler
-// 2) client-side function call statements
-// 3) Content body, which may need to be partitioned
+/**
+ *
+ */
class TCallbackResponse extends THttpResponse
{
private $_writers=array();
@@ -57,4 +51,5 @@ class TCallbackResponseWriter extends TTextWriter return $content;
}
}
-?>
+
+?>
\ No newline at end of file |