summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorwei <>2006-05-05 08:20:50 +0000
committerwei <>2006-05-05 08:20:50 +0000
commit4d70cc125dcd915cdbc8c4f13964d27ebec96eca (patch)
tree3ebd35be9ed02e97a08196817ee330131cf938b4 /framework/Web
parent47d05516b1d1c465217c59732bf8442ab0cfd497 (diff)
Update funky active control example. (see tests/FunctionalTests/features/
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/Javascripts/js/ajax.js7
-rw-r--r--framework/Web/Javascripts/prado/ajax3.js11
-rw-r--r--framework/Web/UI/ActiveControls/TActiveControlAdapter.php2
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLabel.php28
-rw-r--r--framework/Web/UI/ActiveControls/TCallback.php32
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php17
6 files changed, 84 insertions, 13 deletions
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index 5deebd1b..a9d0fd73 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -46,8 +46,11 @@ method.toFunction().apply(this,command[method].concat(transport));else if(typeof
{if(transport.status<500)
{var msg='HTTP '+transport.status+" with response : \n";msg+=transport.responseText+"\n";msg+="Data : \n"+inspect(data)+"\n";msg+="Actions : \n";request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER).each(function(action)
{msg+=inspect(action)+"\n";})
-Logger.warn(msg);}},onException:function(e)
-{Logger.error('Uncaught Callback Client Exception:',e);},formatException:function(e)
+Logger.warn(msg);}},onException:function(request,e)
+{msg="";for(var v in e)
+{if(typeof(v[e])!="object"&&typeof(v[e])!="function")
+msg+=v+":"+e[v]+"\n";}
+Logger.error('Uncaught Callback Client Exception:',e);},formatException:function(e)
{var msg=e.type+" with message \""+e.message+"\"";msg+=" in "+e.file+"("+e.line+")\n";msg+="Stack trace:\n";var trace=e.trace;for(var i=0;i<trace.length;i++)
{msg+=" #"+i+" "+trace[i].file;msg+="("+trace[i].line+"): ";msg+=trace[i]["class"]+"->"+trace[i]["function"]+"()"+"\n";}
msg+=e.version+" "+e.time+"\n";return msg;}},encode:function(data)
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index 2caaf553..15f60631 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -19,8 +19,7 @@ Object.extend(Ajax.Request.prototype,
Prado.CallbackRequest.updatePageState(this,transport);
Ajax.Responders.dispatch('on' + transport.status, this, transport, json);
Prado.CallbackRequest.dispatchActions(transport,this.getHeaderData(Prado.CallbackRequest.ACTION_HEADER));
-
-
+
(this.options['on' + this.transport.status]
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
|| Prototype.emptyFunction)(transport, json);
@@ -179,8 +178,14 @@ Object.extend(Prado.CallbackRequest,
/**
* Uncaught exceptions during callback response.
*/
- onException : function(e)
+ onException : function(request,e)
{
+ msg = "";
+ for(var v in e)
+ {
+ if(typeof(v[e]) != "object" && typeof(v[e]) != "function")
+ msg += v+":"+e[v]+"\n";
+ }
Logger.error('Uncaught Callback Client Exception:', e);
},
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 77973b2c..6b410edd 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -20,6 +20,8 @@ class TActiveControlAdapter extends TControlAdapter
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 3216be43..7e5a8084 100644
--- a/framework/Web/UI/ActiveControls/TActiveLabel.php
+++ b/framework/Web/UI/ActiveControls/TActiveLabel.php
@@ -36,6 +36,30 @@ class TActiveLabel extends TLabel
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();
+ }
/**
* On callback response, the inner HTMl of the label is updated.
@@ -44,7 +68,7 @@ class TActiveLabel extends TLabel
public function setText($value)
{
parent::setText($value);
- if($this->getIsInitialized())
+ if($this->canUpdateClientSide())
{
$this->getPage()->getCallbackClient()->update($this, $value);
}
@@ -59,7 +83,7 @@ class TActiveLabel extends TLabel
public function setForControl($value)
{
parent::setForControl($value);
- if($this->getIsInitialized())
+ if($this->canUpdateClientSide())
{
$id=$this->findControl($value)->getClientID();
$this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id);
diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php
index 9d2301d8..f42b3143 100644
--- a/framework/Web/UI/ActiveControls/TCallback.php
+++ b/framework/Web/UI/ActiveControls/TCallback.php
@@ -1,9 +1,29 @@
<?php
-
-/*
- * Created on 25/04/2006
+/**
+ * TCallback 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
*/
+/**
+ * TCallback component class.
+ *
+ * The TCallback provides a basic callback handler that can be invoke from the
+ * client side by running the javascript code obtained from the
+ * {@link getCallbackReference CallbackReference} property. The event {@link
+ * onCallback OnCallback} is raise when a callback is requested by the TCallback
+ * component.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.0
+ */
class TCallback extends TControl implements ICallbackEventHandler
{
/**
@@ -138,12 +158,14 @@ class TCallback extends TControl implements ICallbackEventHandler
* 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()
+ public function getCallbackReference($control=null)
{
$client = $this->getPage()->getClientScript();
- return $client->getCallbackReference($this, $this->getCallbackOptions());
+ $object = is_null($control) ? $this : $control;
+ return $client->getCallbackReference($object, $this->getCallbackOptions());
}
}
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
index c0a817f0..8c6732e3 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
@@ -1,5 +1,15 @@
<?php
-
+/**
+ * TCallbackClientSideOptions class file
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[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
+ */
+
/**
* TCallbackClientSideOptions class.
*
@@ -30,6 +40,11 @@
* - <b>EnablePageStateUpdate</b> enable the callback response to enable the
* viewstate update. This will automatically set HasPrority to true when
* enabled.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.0
*/
class TCallbackClientSideOptions extends TClientSideOptions
{