summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorwei <>2006-05-05 00:45:35 +0000
committerwei <>2006-05-05 00:45:35 +0000
commitf21d3433721308f5d0693f44bbfed56f7b2ecc2d (patch)
tree96f10eb302f0a156ebc237d9ab0949986c4f469e /framework/Web/UI
parent42df6f47862c2f1495ded49f758dbc46f9d9e930 (diff)
Adding TActiveLabel
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLabel.php70
-rw-r--r--framework/Web/UI/ActiveControls/TActivePageAdapter.php2
-rw-r--r--framework/Web/UI/ActiveControls/TCallback.php19
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientScript.php14
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php16
-rw-r--r--framework/Web/UI/TPage.php33
6 files changed, 125 insertions, 29 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveLabel.php b/framework/Web/UI/ActiveControls/TActiveLabel.php
new file mode 100644
index 00000000..d71d8b7a
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveLabel.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * TActiveLabel class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TActiveLabel class
+ *
+ * The active control counterpart of TLabel component. During a callback
+ * request, setting {@link setText Text} property will also set the text of the
+ * label on the client upon callback completion. Similarly, setting {@link
+ * setForControl ForControl} will set the client-side for attribute on the
+ * label.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.0
+ */
+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.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * On callback response, the inner HTMl of the label is updated.
+ * @param string the text value of the label
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->getPage()->getAllowCallbackUpdate())
+ {
+ $this->getPage()->getCallbackClient()->update($this, $value);
+ }
+ }
+
+ /**
+ * Sets the ID of the control that the label is associated with.
+ * The control must be locatable via {@link TControl::findControl} using the ID.
+ * On callback response, the For attribute of the label is updated.
+ * @param string the associated control ID
+ */
+ public function setForControl($value)
+ {
+ parent::setForControl($value);
+ if($this->getPage()->getAllowCallbackUpdate())
+ {
+ $id=$this->findControl($value)->getClientID();
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id);
+ }
+ }
+}
+
+?>
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index 4cb785dd..db783a12 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -285,7 +285,7 @@ class TCallbackErrorHandler extends TErrorHandler
{
$response = $this->getApplication()->getResponse();
$data = TJavascript::jsonEncode($this->getExceptionData($exception));
- $response->appendHeader('HTTP/1.0 505 Internal Error');
+ $response->appendHeader('HTTP/1.0 500 Internal Error');
$response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$data);
}
else
diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php
index d3b1f54d..9c3234fd 100644
--- a/framework/Web/UI/ActiveControls/TCallback.php
+++ b/framework/Web/UI/ActiveControls/TCallback.php
@@ -4,7 +4,7 @@
* Created on 25/04/2006
*/
-class TCallback extends TWebControl implements ICallbackEventHandler
+class TCallback extends TControl implements ICallbackEventHandler
{
/**
* @var TCallbackClientSideOptions client-side options.
@@ -21,15 +21,7 @@ class TCallback extends TWebControl implements ICallbackEventHandler
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
}
-
- /**
- * @return string tag name of the panel
- */
- protected function getTagName()
- {
- return 'div';
- }
-
+
/**
* @return boolean whether callback event trigger by this button will cause
* input validation, default is true
@@ -153,13 +145,6 @@ class TCallback extends TWebControl implements ICallbackEventHandler
$client = $this->getPage()->getClientScript();
return $client->getCallbackReference($this, $this->getCallbackOptions());
}
-
- public function render($writer)
- {
- parent::render($writer);
- if($this->getPage()->getIsCallback())
- $this->getPage()->getCallbackClient()->replace($this, $writer);
- }
}
?>
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index aaf81380..5f8851db 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -318,20 +318,16 @@ class TCallbackClientScript extends TApplicationComponent
if($content instanceof TControl)
{
$boundary = $this->getRenderedContentBoundary($content);
- $this->callClientFunction('Prado.Element.replaceContent',
- array($element, $method, null, $boundary));
+ $content = null;
}
else if($content instanceof THtmlWriter)
{
$boundary = $this->getResponseContentBoundary($content);
- $this->callClientFunction('Prado.Element.replaceContent',
- array($element, $method, null, $boundary));
- }
- else
- {
- $this->callClientFunction('Prado.Element.replaceContent',
- array($element, $method, $content, $boundary));
+ $content = null;
}
+
+ $this->callClientFunction('Prado.Element.replace',
+ array($element, $method, $content, $boundary));
}
/**
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
index 1e1bd52f..6a4731f7 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
@@ -216,6 +216,22 @@ class TCallbackClientSideOptions extends TClientSideOptions
{
$this->getOptions()->add('PostState', TPropertyValue::ensureBoolean($value));
}
+
+ /**
+ * @return integer callback request timeout.
+ */
+ public function getRequestTimeOut()
+ {
+ return $this->getOption('TimeOut');
+ }
+
+ /**
+ * @param integer callback request timeout
+ */
+ public function setRequestTimeOut($value)
+ {
+ $this->getOptions()->add('TimeOut', TPropertyValue::ensureInteger($value));
+ }
}
?>
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 94f1f475..11ebc1dd 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -37,7 +37,7 @@ class TPage extends TTemplateControl
const FIELD_PAGESTATE='PRADO_PAGESTATE';
const FIELD_CALLBACK_TARGET='PRADO_CALLBACK_TARGET';
const FIELD_CALLBACK_PARAMETER='PRADO_CALLBACK_PARAMETER';
-// const FIELD_CALLBACK_ID='PRADO_CALLBACK_ID';
+
/**
* @var array system post fields
*/
@@ -48,7 +48,6 @@ class TPage extends TTemplateControl
'PRADO_PAGESTATE'=>true,
'PRADO_CALLBACK_TARGET'=>true,
'PRADO_CALLBACK_PARAMETER'=>true
- //'PRADO_CALLBACK_ID'=>true
);
/**
* @var TForm form instance
@@ -154,6 +153,11 @@ class TPage extends TTemplateControl
* @var array post data loader IDs.
*/
private $_postDataLoaders=array();
+ /**
+ * @var boolean true if callback request is allowed to update the client-
+ * side contents during callback response.
+ */
+ private $_allowCallbackUpdate=false;
/**
* Constructor.
@@ -278,6 +282,8 @@ class TPage extends TTemplateControl
Prado::trace("Page initRecursive()",'System.Web.UI.TPage');
$this->initRecursive();
+ $this->setAllowCallbackUpdate(true);
+
Prado::trace("Page onInitComplete()",'System.Web.UI.TPage');
$this->onInitComplete(null);
@@ -295,6 +301,7 @@ class TPage extends TTemplateControl
Prado::trace("Page raiseChangedEvents()",'System.Web.UI.TPage');
$this->raiseChangedEvents();
+
$this->getAdapter()->processCallbackEvent($writer);
/*
@@ -324,6 +331,28 @@ class TPage extends TTemplateControl
}
/**
+ * Returns true if callback request is allowed to update the client- side
+ * contents during callback response. Default is true if {@link
+ * getIsCallback IsCallback} is true and onInit stage has been completed.
+ * @return boolean true to allow client-side update.
+ */
+ public function getAllowCallbackUpdate()
+ {
+ return $this->_allowCallbackUpdate;
+ }
+
+ /**
+ * Set to true to allow callback request to update client-side content
+ * during callback response. Default is true if {@link getIsCallback
+ * IsCallback} is true and onInit stage has been completed.
+ * @param boolean true to allow callback to update client-side content.
+ */
+ public function setAllowCallbackUpdate($value)
+ {
+ $this->_allowCallbackUpdate = TPropertyValue::ensureBoolean($value);
+ }
+
+ /**
* Gets the callback client script handler that allows javascript functions
* to be executed during the callback response.
* @return TCallbackClientScript interface to client-side javascript code.