summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2006-05-06 02:26:20 +0000
committerwei <>2006-05-06 02:26:20 +0000
commita7f6c6640ac9295eec3ae2edbb2250179eb85e33 (patch)
tree8a3879c747dfc3bcd5d65f334341ea7c81ced268
parent46155621cbf97191fca495cbd09a2eedd82afa82 (diff)
Adding TActiveButton and TActiveTextBox
-rw-r--r--.gitattributes6
-rw-r--r--buildscripts/jsbuilder/build.php3
-rw-r--r--framework/Web/Javascripts/extra/behaviour.js68
-rw-r--r--framework/Web/Javascripts/extra/getElementsBySelector.js176
-rw-r--r--framework/Web/Javascripts/js/ajax.js22
-rw-r--r--framework/Web/Javascripts/prado/ajax3.js38
-rw-r--r--framework/Web/UI/ActiveControls/TActiveButton.php141
-rw-r--r--framework/Web/UI/ActiveControls/TActiveControlAdapter.php4
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLabel.php6
-rw-r--r--framework/Web/UI/ActiveControls/TActivePageAdapter.php1
-rw-r--r--framework/Web/UI/ActiveControls/TActiveTextBox.php139
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php10
-rw-r--r--framework/Web/UI/TClientScriptManager.php21
-rw-r--r--framework/Web/UI/TControl.php8
-rw-r--r--framework/Web/UI/WebControls/TBulletedList.php11
-rw-r--r--framework/Web/UI/WebControls/TButton.php23
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php11
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php20
-rw-r--r--framework/Web/UI/WebControls/TImageMap.php11
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php19
-rw-r--r--framework/Web/UI/WebControls/TListControl.php15
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php11
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php15
-rw-r--r--tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.page24
-rw-r--r--tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php8
-rw-r--r--tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.page29
-rw-r--r--tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php14
27 files changed, 529 insertions, 325 deletions
diff --git a/.gitattributes b/.gitattributes
index 200e5d7b..329e6e51 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -867,8 +867,6 @@ framework/Web/Javascripts/extended/builder.js -text
framework/Web/Javascripts/extended/date.js -text
framework/Web/Javascripts/extended/event.js -text
framework/Web/Javascripts/extended/string.js -text
-framework/Web/Javascripts/extra/behaviour.js -text
-framework/Web/Javascripts/extra/getElementsBySelector.js -text
framework/Web/Javascripts/extra/json.js -text
framework/Web/Javascripts/extra/logger.js -text
framework/Web/Javascripts/js/ajax.js -text
@@ -927,10 +925,12 @@ framework/Web/THttpRequest.php -text
framework/Web/THttpResponse.php -text
framework/Web/THttpSession.php -text
framework/Web/THttpUtility.php -text
+framework/Web/UI/ActiveControls/TActiveButton.php -text
framework/Web/UI/ActiveControls/TActiveControlAdapter.php -text
framework/Web/UI/ActiveControls/TActiveLabel.php -text
framework/Web/UI/ActiveControls/TActivePageAdapter.php -text
framework/Web/UI/ActiveControls/TActivePanel.php -text
+framework/Web/UI/ActiveControls/TActiveTextBox.php -text
framework/Web/UI/ActiveControls/TCallback.php -text
framework/Web/UI/ActiveControls/TCallbackClientScript.php -text
framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php -text
@@ -1041,6 +1041,8 @@ tests/FunctionalTests/features/protected/controls/Layout.php -text
tests/FunctionalTests/features/protected/controls/Layout.tpl -text
tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.page -text
tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php -text
+tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.page -text
+tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php -text
tests/FunctionalTests/features/protected/pages/ActiveControls/config.xml -text
tests/FunctionalTests/features/protected/pages/ColorPicker.page -text
tests/FunctionalTests/features/protected/pages/CompositeControl.page -text
diff --git a/buildscripts/jsbuilder/build.php b/buildscripts/jsbuilder/build.php
index 80e6b3ee..9cd1da74 100644
--- a/buildscripts/jsbuilder/build.php
+++ b/buildscripts/jsbuilder/build.php
@@ -101,7 +101,8 @@ $libraries = array(
'ajax.js' => array(
'prototype/ajax.js',
'prado/ajax3.js',
- 'extra/json.js'
+ 'extra/json.js',
+ 'prado/activecontrols3.js'
/* 'effects/controls.js',
'effects/dragdrop.js',
'effects/slider.js',
diff --git a/framework/Web/Javascripts/extra/behaviour.js b/framework/Web/Javascripts/extra/behaviour.js
deleted file mode 100644
index ac9adeda..00000000
--- a/framework/Web/Javascripts/extra/behaviour.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
- of Simon Willison (see comments by Simon below).
-
- Description:
-
- Uses css selectors to apply javascript behaviours to enable
- unobtrusive javascript in html documents.
-
- Usage:
-
- var myrules = {
- 'b.someclass' : function(element){
- element.onclick = function(){
- alert(this.innerHTML);
- }
- },
- '#someid u' : function(element){
- element.onmouseover = function(){
- this.innerHTML = "BLAH!";
- }
- }
- };
-
- Behaviour.register(myrules);
-
- // Call Behaviour.apply() to re-apply the rules (if you
- // update the dom, etc).
-
- License:
-
- This file is entirely BSD licensed.
-
- More information:
-
- http://ripcord.co.nz/behaviour/
-
-*/
-
-var Behaviour = {
- list : new Array,
-
- register : function(sheet){
- Behaviour.list.push(sheet);
- },
-
- start : function(){
- Event.OnLoad(Behaviour.apply);
- },
-
- apply : function(){
- for (h=0;sheet=Behaviour.list[h];h++){
- for (selector in sheet){
- list = document.getElementsBySelector(selector);
-
- if (!list){
- continue;
- }
-
- for (i=0;element=list[i];i++){
- sheet[selector](element);
- }
- }
- }
- }
-}
-
-Behaviour.start(); \ No newline at end of file
diff --git a/framework/Web/Javascripts/extra/getElementsBySelector.js b/framework/Web/Javascripts/extra/getElementsBySelector.js
deleted file mode 100644
index 592872fc..00000000
--- a/framework/Web/Javascripts/extra/getElementsBySelector.js
+++ /dev/null
@@ -1,176 +0,0 @@
-/** document.getElementsBySelector(selector)
- - returns an array of element objects from the current document
- matching the CSS selector. Selectors can contain element names,
- class names and ids and can be nested. For example:
-
- elements = document.getElementsBySelect('div#main p a.external')
-
- Will return an array of all 'a' elements with 'external' in their
- class attribute that are contained inside 'p' elements that are
- contained inside the 'div' element which has id="main"
-
- New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
- See http://www.w3.org/TR/css3-selectors/#attribute-selectors
-
- Version 0.4 - Simon Willison, March 25th 2003
- -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
- -- Opera 7 fails
-*/
-
-/**
- * Returns all children of element. Workaround required for IE5/Windo
- */
-function getAllChildren(e) {
- // Returns all children of element. Workaround required for IE5/Windows. Ugh.
- return e.all ? e.all : e.getElementsByTagName('*');
-}
-
-/**
- * returns an array of element objects from the current document
- matching the CSS selector. Selectors can contain element names,
- class names and ids and can be nested. For example:
-
- <pre><tt>elements = $CSS('div#main p a.external')</tt></pre>
-
- Will return an array of all 'a' elements with 'external' in their
- class attribute that are contained inside 'p' elements that are
- contained inside the 'div' element which has id="main"
- */
-$CSS = function(selector) {
- // Attempt to fail gracefully in lesser browsers
- if (!document.getElementsByTagName) {
- return new Array();
- }
- // Split selector in to tokens
- var tokens = selector.split(' ');
- var currentContext = new Array(document);
- for (var i = 0; i < tokens.length; i++) {
- token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
- if (token.indexOf('#') > -1) {
- // Token is an ID selector
- var bits = token.split('#');
- var tagName = bits[0];
- var id = bits[1];
- var element = document.getElementById(id);
- if (tagName && element.nodeName.toLowerCase() != tagName) {
- // tag with that ID not found, return false
- return new Array();
- }
- // Set currentContext to contain just this element
- currentContext = new Array(element);
- continue; // Skip to next token
- }
- if (token.indexOf('.') > -1) {
- // Token contains a class selector
- var bits = token.split('.');
- var tagName = bits[0];
- var className = bits[1];
- if (!tagName) {
- tagName = '*';
- }
- // Get elements matching tag, filter them for class selector
- var found = new Array;
- var foundCount = 0;
- for (var h = 0; h < currentContext.length; h++) {
- var elements;
- if (tagName == '*') {
- elements = getAllChildren(currentContext[h]);
- } else {
- elements = currentContext[h].getElementsByTagName(tagName);
- }
- for (var j = 0; j < elements.length; j++) {
- found[foundCount++] = elements[j];
- }
- }
- currentContext = new Array;
- var currentContextIndex = 0;
- for (var k = 0; k < found.length; k++) {
- if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
- currentContext[currentContextIndex++] = found[k];
- }
- }
- continue; // Skip to next token
- }
- // Code to deal with attribute selectors
- if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
- var tagName = RegExp.$1;
- var attrName = RegExp.$2;
- var attrOperator = RegExp.$3;
- var attrValue = RegExp.$4;
- if (!tagName) {
- tagName = '*';
- }
- // Grab all of the tagName elements within current context
- var found = new Array;
- var foundCount = 0;
- for (var h = 0; h < currentContext.length; h++) {
- var elements;
- if (tagName == '*') {
- elements = getAllChildren(currentContext[h]);
- } else {
- elements = currentContext[h].getElementsByTagName(tagName);
- }
- for (var j = 0; j < elements.length; j++) {
- found[foundCount++] = elements[j];
- }
- }
- currentContext = new Array;
- var currentContextIndex = 0;
- var checkFunction; // This function will be used to filter the elements
- switch (attrOperator) {
- case '=': // Equality
- checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
- break;
- case '~': // Match one of space seperated words
- checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
- break;
- case '|': // Match start with value followed by optional hyphen
- checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
- break;
- case '^': // Match starts with value
- checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
- break;
- case '$': // Match ends with value - fails with "Warning" in Opera 7
- checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
- break;
- case '*': // Match ends with value
- checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
- break;
- default :
- // Just test for existence of attribute
- checkFunction = function(e) { return e.getAttribute(attrName); };
- }
- currentContext = new Array;
- var currentContextIndex = 0;
- for (var k = 0; k < found.length; k++) {
- if (checkFunction(found[k])) {
- currentContext[currentContextIndex++] = found[k];
- }
- }
- // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
- continue; // Skip to next token
- }
- // If we get here, token is JUST an element (not a class or ID selector)
- tagName = token;
- var found = new Array;
- var foundCount = 0;
- for (var h = 0; h < currentContext.length; h++) {
- var elements = currentContext[h].getElementsByTagName(tagName);
- for (var j = 0; j < elements.length; j++) {
- found[foundCount++] = elements[j];
- }
- }
- currentContext = found;
- }
- return currentContext;
-}
-
-/* That revolting regular expression explained
-/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
- \---/ \---/\-------------/ \-------/
- | | | |
- | | | The value
- | | ~,|,^,$,* or =
- | Attribute
- Tag
-*/
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index a9d0fd73..e082c7bb 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -44,8 +44,9 @@ method.toFunction().apply(this,command[method].concat(transport));else if(typeof
{Logger.error("Error in executing callback response:","Unable to find HTML element with ID '"+id+"' before executing "+method+"().");}}}},Exception:{"on500":function(request,transport,data)
{var e=request.getHeaderData(Prado.CallbackRequest.ERROR_HEADER);Logger.error("Callback Server Error "+e.code,this.formatException(e));},'on200':function(request,transport,data)
{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";})
+{var msg='HTTP '+transport.status+" with response : \n";msg+=transport.responseText+"\n";msg+="Data : \n"+inspect(data)+"\n";msg+="Actions : \n";data=request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER);if(data&&data.length>0)
+{data.each(function(action)
+{msg+=inspect(action)+"\n";});}
Logger.warn(msg);}},onException:function(request,e)
{msg="";for(var v in e)
{if(typeof(v[e])!="object"&&typeof(v[e])!="function")
@@ -62,18 +63,22 @@ return null;},dispatchPriorityRequest:function(callback)
this.abortRequestInProgress();callback.request=new Ajax.Request(callback.url,callback.options);callback.timeout=setTimeout(function()
{Logger.warn("priority timeout");Prado.CallbackRequest.abortRequestInProgress();},callback.options.RequestTimeOut);this.requestInProgress=callback;Logger.info("dispatched "+this.requestInProgress)},dispatchNormalRequest:function(callback)
{Logger.info("dispatching normal request");new Ajax.Request(callback.url,callback.options);},abortRequestInProgress:function()
-{inProgress=Prado.CallbackRequest.requestInProgress;if(inProgress)
+{inProgress=Prado.CallbackRequest.requestInProgress;Logger.info("aborting ... "+inProgress);if(inProgress)
{Logger.warn("aborted "+inProgress.id)
-inProgress.request.transport.abort();clearTimeout(inProgress.timeout);Prado.CallbackRequest.requestInProgress=null;}},updatePageState:function(request,transport)
+inProgress.request.transport.abort();clearTimeout(inProgress.timeout);Prado.CallbackRequest.requestInProgress=null;return true;}
+return false;},updatePageState:function(request,transport)
{pagestate=$(this.FIELD_CALLBACK_PAGESTATE);if(request.options.EnablePageStateUpdate&&request.options.HasPriority&&pagestate)
-{Logger.warn("updating page state");pagestate.value=request.header(this.PAGESTATE_HEADER);}}})
+{data=request.header(this.PAGESTATE_HEADER);if(typeof(data)=="string"&&data.length>0)
+{Logger.warn("updating page state");pagestate.value=data;}
+else
+{Logger.debug("Bad page state:"+data);}}}})
Ajax.Responders.register({onComplete:function(request)
{if(request.options.HasPriority)
Prado.CallbackRequest.abortRequestInProgress();}});Event.OnLoad(function()
{if(typeof Logger!="undefined")
Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackRequest.prototype={url:window.location.href,options:{},id:null,request:null,initialize:function(id,options)
-{this.id=id;this.options={RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true,postBody:this._getPostData(),parameters:''}
-Object.extend(this.options,options||{});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined")
+{this.id=id;this.options={RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true}
+Object.extend(this.options,options||{});Object.extend(this.options,{postBody:this._getPostData(),parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined")
{var form=this.options.Form||Prado.Validation.getForm();if(Prado.Validation.validate(form,this.options.ValidationGroup,this)==false)
return;}
if(this.options.HasPriority)
@@ -127,4 +132,5 @@ break;case'n':if(next()=='u'&&next()=='l'&&next()=='l'){next();return null;}
break;}
error("Syntax error");}
function value(){white();switch(ch){case'{':return object();case'[':return array();case'"':return string();case'-':return number();default:return ch>='0'&&ch<='9'?number():word();}}
-return value();}}; \ No newline at end of file
+return value();}};Prado.WebUI.CallbackControl=Class.extend(Prado.WebUI.PostBackControl,{onPostBack:function(event,options)
+{new Prado.CallbackRequest(options.EventTarget,options);Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl); \ No newline at end of file
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index 15f60631..b21e9429 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -167,10 +167,14 @@ Object.extend(Prado.CallbackRequest,
msg += transport.responseText + "\n";
msg += "Data : \n"+inspect(data)+"\n";
msg += "Actions : \n";
- request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER).each(function(action)
+ data = request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER);
+ if(data && data.length > 0)
{
- msg += inspect(action)+"\n";
- })
+ data.each(function(action)
+ {
+ msg += inspect(action)+"\n";
+ });
+ }
Logger.warn(msg);
}
},
@@ -262,13 +266,16 @@ Object.extend(Prado.CallbackRequest,
abortRequestInProgress : function()
{
inProgress = Prado.CallbackRequest.requestInProgress;
+ Logger.info("aborting ... "+inProgress);
if(inProgress)
{
Logger.warn("aborted "+inProgress.id)
inProgress.request.transport.abort();
clearTimeout(inProgress.timeout);
Prado.CallbackRequest.requestInProgress = null;
+ return true;
}
+ return false;
},
/**
@@ -280,8 +287,16 @@ Object.extend(Prado.CallbackRequest,
pagestate = $(this.FIELD_CALLBACK_PAGESTATE);
if(request.options.EnablePageStateUpdate && request.options.HasPriority && pagestate)
{
- Logger.warn("updating page state");
- pagestate.value = request.header(this.PAGESTATE_HEADER);
+ data = request.header(this.PAGESTATE_HEADER);
+ if(typeof(data) == "string" && data.length > 0)
+ {
+ Logger.warn("updating page state");
+ pagestate.value = data;
+ }
+ else
+ {
+ Logger.debug("Bad page state:"+data);
+ }
}
}
})
@@ -341,12 +356,17 @@ Prado.CallbackRequest.prototype =
HasPriority : true,
CausesValidation : true,
ValidationGroup : null,
- PostInputs : true,
- postBody : this._getPostData(),
- parameters : ''
+ PostInputs : true
}
Object.extend(this.options, options || {});
-
+
+ //override parameter and postBody options.
+ Object.extend(this.options,
+ {
+ postBody : this._getPostData(),
+ parameters : ''
+ });
+
if(this.options.CausesValidation && typeof(Prado.Validation) != "undefined")
{
var form = this.options.Form || Prado.Validation.getForm();
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php
new file mode 100644
index 00000000..db4fa85d
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveButton.php
@@ -0,0 +1,141 @@
+<?php
+/*
+ * Created on 5/05/2006
+ */
+
+class TActiveButton extends TButton implements ICallbackEventHandler
+{
+ /**
+ * @var TCallbackClientSideOptions client-side options.
+ */
+ private $_clientSide;
+
+ /**
+ * 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, by calling this constructor.
+ */
+ public function __construct()
+ {
+ 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();
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface. If {@link getCausesValidation
+ * CausesValidation} is true, it will invoke the page's {@link TPage::
+ * validate validate} method first. It will raise {@link onCallback
+ * 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);
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * 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);
+ }
+
+ /**
+ * @param string caption of the button
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
+ }
+
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallback ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSideOptions} for details on the properties of
+ * ClientSide.
+ * @return TCallbackClientSideOptions client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if(is_null($this->_clientSide))
+ $this->_clientSide = $this->createClientSideOptions();
+ return $this->_clientSide;
+ }
+
+ /**
+ * @return TCallbackClientSideOptions callback client-side options.
+ */
+ protected function createClientSideOptions()
+ {
+ return new TCallbackClientSideOptions;
+ }
+
+ /**
+ * Renders the callback control javascript statement.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerCallbackControl(get_class($this),$this->getCallbackOptions());
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getCallbackOptions()
+ {
+ return array_merge($this->getPostBackOptions(),
+ $this->getClientSide()->getOptions()->toArray());
+ }
+
+ /**
+ * 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($control=null)
+ {
+ $client = $this->getPage()->getClientScript();
+ $object = is_null($control) ? $this : $control;
+ return $client->getCallbackReference($object, $this->getPostBackOptions());
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 6b410edd..2409d9fe 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -15,13 +15,13 @@ class TActiveControlAdapter extends TControlAdapter
if(!self::$_renderedPosts)
{
$options = TJavascript::encode($this->getPage()->getPostDataLoaders(),false);
- $script = "Prado.CallbackRequest.PostDataLoaders.concat({$options});";
+ $script = "Prado.CallbackRequest.PostDataLoaders = {$options};";
$this->getPage()->getClientScript()->registerEndScript(get_class($this), $script);
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 7e5a8084..13a88b4f 100644
--- a/framework/Web/UI/ActiveControls/TActiveLabel.php
+++ b/framework/Web/UI/ActiveControls/TActiveLabel.php
@@ -58,7 +58,9 @@ class TActiveLabel extends TLabel
*/
protected function canUpdateClientSide()
{
- return $this->getIsInitialized() && $this->getAllowCallbackUpdate();
+ return $this->getIsInitialized()
+ && $this->getPage()->getIsCallback()
+ && $this->getAllowCallbackUpdate();
}
/**
@@ -69,9 +71,7 @@ class TActiveLabel extends TLabel
{
parent::setText($value);
if($this->canUpdateClientSide())
- {
$this->getPage()->getCallbackClient()->update($this, $value);
- }
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index 67720afd..11c3303e 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -76,7 +76,6 @@ class TActivePageAdapter extends TControlAdapter
{
Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
$this->renderResponse($writer);
- //$this->getResponse()->flush();
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
new file mode 100644
index 00000000..ad28b291
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -0,0 +1,139 @@
+<?php
+/*
+ * Created on 6/05/2006
+ */
+
+class TActiveTextBox extends TTextBox implements ICallbackEventHandler
+{
+ /**
+ * @var TCallbackClientSideOptions client-side options.
+ */
+ private $_clientSide;
+
+ /**
+ * 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, by calling this constructor.
+ */
+ public function __construct()
+ {
+ 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->getPage()->getIsCallback()
+ && $this->getAllowCallbackUpdate();
+ }
+
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallback ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSideOptions} for details on the properties of
+ * ClientSide.
+ * @return TCallbackClientSideOptions client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if(is_null($this->_clientSide))
+ $this->_clientSide = $this->createClientSideOptions();
+ return $this->_clientSide;
+ }
+
+ /**
+ * @return TCallbackClientSideOptions callback client-side options.
+ */
+ protected function createClientSideOptions()
+ {
+ return new TCallbackClientSideOptions;
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface. It class raisePostDataChangedEvent
+ * first then raises {@link onCallback OnCallback} event. This method is
+ * mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->raisePostDataChangedEvent();
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * 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);
+ }
+
+ /**
+ * Client-side Text property can only be updated after the OnLoad stage.
+ * @param string text content for the textbox
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->canUpdateClientSide() && $this->getHasLoadedPostData())
+ $this->getPage()->getCallbackClient()->setValue($this, $value);
+ }
+
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerCallbackControl(get_class($this),$this->getCallbackOptions());
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getCallbackOptions()
+ {
+ return array_merge($this->getPostBackOptions(),
+ $this->getClientSide()->getOptions()->toArray());
+ }
+
+ /**
+ * 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($control=null)
+ {
+ $client = $this->getPage()->getClientScript();
+ $object = is_null($control) ? $this : $control;
+ return $client->getCallbackReference($object, $this->getPostBackOptions());
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
index 8c6732e3..3eadcd29 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
@@ -221,11 +221,12 @@ class TCallbackClientSideOptions extends TClientSideOptions
/**
* @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.
+ * affect callbacks that are not prioritized. Default is true.
*/
public function getHasPriority()
{
- return $this->getOption('HasPriority');
+ $option = $this->getOption('HasPriority');
+ return is_null($option) ? true : $option;
}
/**
@@ -257,11 +258,12 @@ class TCallbackClientSideOptions extends TClientSideOptions
/**
* @return boolean client-side viewstate will be updated on callback
- * response if true.
+ * response if true. Default is true.
*/
public function getEnablePageStateUpdate()
{
- return $this->getOption('EnablePageStateUpdate');
+ $option = $this->getOption('EnablePageStateUpdate');
+ return is_null($option) ? true : $option;
}
}
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index 20612ce2..cad317ef 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -177,16 +177,33 @@ class TClientScriptManager extends TApplicationComponent
}
/**
+ * Registers callback javascript for a control.
+ * @param string javascript class responsible for the control being registered for callback
+ * @param array callback options
+ */
+ public function registerCallbackControl($class, $options)
+ {
+ $optionString=TJavaScript::encode($options);
+ $code="new Prado.WebUI.{$class}({$optionString});";
+ $this->_endScripts[sprintf('%08X', crc32($code))]=$code;
+ $this->registerPradoScriptInternal('ajax');
+
+ $params=func_get_args();
+ foreach($this->_page->getCachingStack() as $item)
+ $item->registerAction('Page.ClientScript','registerCallbackControl',$params);
+ }
+
+ /**
* Registers postback javascript for a control.
* @param string javascript class responsible for the control being registered for postback
* @param array postback options
*/
- public function registerPostBackControl($jsClass,$options)
+ public function registerPostBackControl($class,$options)
{
if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null)
$options['FormID']=$form->getClientID();
$optionString=TJavaScript::encode($options);
- $code="new $jsClass($optionString);";
+ $code="new Prado.WebUI.{$class}({$optionString});";
$this->_endScripts[sprintf('%08X', crc32($code))]=$code;
$this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET]='';
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 3bb893e2..7121e5ed 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -1005,6 +1005,14 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
{
return $this->getControlStage() >= self::CS_CHILD_INITIALIZED;
}
+
+ /**
+ * @return boolean true if the control has loaded post data.
+ */
+ public function getHasLoadedPostData()
+ {
+ return $this->getControlStage() >= self::CS_LOADED;
+ }
/**
* Returns the named registered object.
diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php
index 05cbaab1..fad77232 100644
--- a/framework/Web/UI/WebControls/TBulletedList.php
+++ b/framework/Web/UI/WebControls/TBulletedList.php
@@ -321,9 +321,9 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
else
{
$this->_currentRenderItemIndex = $index;
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TBulletedList',$this->getPostBackOptions());
$writer->addAttribute('id', $this->getClientID().$index);
$writer->addAttribute('href', "javascript:;//".$this->getClientID().$index);
+ $this->renderClientControlScript($writer);
}
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -331,6 +331,15 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
$writer->write(THttpUtility::htmlEncode($item->getText()));
$writer->renderEndTag();
}
+
+ /**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
/**
* @return array postback options used for linkbuttons.
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index b9872a64..ba523168 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -72,14 +72,8 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
$writer->addAttribute('value',$this->getText());
- if($this->getEnabled(true))
- {
- if($this->canCauseValidation())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TButton',$this->getPostBackOptions());
- }
- }
+ if($this->getEnabled(true) )
+ $this->renderClientControlScript($writer);
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
@@ -87,6 +81,19 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ if($this->canCauseValidation())
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+ }
+
+ /**
* @return boolean whether to perform validation if the button is clicked
*/
protected function canCauseValidation()
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index da389948..cb8fb30d 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -351,7 +351,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$page=$this->getPage();
if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- $page->getClientScript()->registerPostBackControl('Prado.WebUI.TCheckBox',$this->getPostBackOptions());
+ $this->renderClientControlScript($writer);
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -364,6 +364,15 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+
+ /**
* Gets the post back options for this checkbox.
* @return array
*/
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index 109f53a8..4b482721 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -88,19 +88,25 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
if($this->getEnabled(true))
- {
- if($this->canCauseValidation())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TImageButton',$this->getPostBackOptions());
- }
- }
+ $this->renderClientControlScript($writer);
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ if($this->canCauseValidation())
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+ }
+ /**
* @return boolean whether to perform validation if the button is clicked
*/
protected function canCauseValidation()
diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php
index 9444df46..ae2d6be3 100644
--- a/framework/Web/UI/WebControls/TImageMap.php
+++ b/framework/Web/UI/WebControls/TImageMap.php
@@ -109,7 +109,7 @@ class TImageMap extends TImage implements IPostBackEventHandler
$options['EventParameter']="$i";
$options['CausesValidation']=$hotspot->getCausesValidation();
$options['ValidationGroup']=$hotspot->getValidationGroup();
- $cs->registerPostBackControl('Prado.WebUI.TImageMap',$options);
+ $cs->renderClientControlScript($writer,$options);
}
$hotspot->render($writer);
$writer->writeLine();
@@ -118,6 +118,15 @@ class TImageMap extends TImage implements IPostBackEventHandler
$writer->renderEndTag();
}
}
+
+ /**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer,$options)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$options);
+ }
/**
* Raises the postback event.
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index bca4a8f6..7f9baab8 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -81,15 +81,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC
parent::addAttributesToRender($writer);
if($this->getEnabled(true))
- {
- //create unique no-op url references
- $nop = "#".$this->getClientID();
- $writer->addAttribute('href', $nop);
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TLinkButton',$this->getPostBackOptions());
- }
+ $this->renderClientControlScript($writer);
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
}
+
+ /**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ //create unique no-op url references
+ $nop = "#".$this->getClientID();
+ $writer->addAttribute('href', $nop);
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
/**
* Returns postback specifications for the button.
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 1c615edc..1c7fe11b 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -113,16 +113,23 @@ abstract class TListControl extends TDataBoundControl
if($this->getIsMultiSelect())
$writer->addAttribute('multiple','multiple');
if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.'.get_class($this),$this->getPostBackOptions());
- }
+ $this->renderClientControlScript($writer);
if(!$this->getEnabled(true) && $this->getEnabled())
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+
+ /**
* @return array postback options for JS postback code
*/
protected function getPostBackOptions()
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index 9a523b55..6a5ade4d 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -154,7 +154,7 @@ class TRadioButton extends TCheckBox
$page=$this->getPage();
if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- $page->getClientScript()->registerPostBackControl('Prado.WebUI.TRadioButton',$this->getPostBackOptions());
+ $this->renderClientControlScript($writer);
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -165,6 +165,15 @@ class TRadioButton extends TCheckBox
$writer->renderBeginTag('input');
$writer->renderEndTag();
}
+
+ /**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index feea6227..b443fa59 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -143,14 +143,21 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
if($isEnabled && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TTextBox',$this->getPostBackOptions());
- }
+ $this->renderClientControlScript($writer);
parent::addAttributesToRender($writer);
}
/**
+ * Renders the javascript for textbox.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+
+ /**
* Gets the post back options for this textbox.
* @return array
*/
diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.page b/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.page
index c98bae4d..fab91c40 100644
--- a/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.page
+++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.page
@@ -1,16 +1,16 @@
<com:TContent ID="Content">
<h1>TCallback Demo</h1>
- <com:TClientScript UsingPradoScripts="ajax" />
<com:TCallback id="control1"
ClientSide.EnablePageStateUpdate="false"
OnCallback="slowResponse" />
-
- <com:TCallback id="control2"
- ClientSide.HasPriority="false"
- OnCallback="fastResponse" />
-
+
<com:TActiveLabel id="label1" Text="Name:" AllowCallbackUpdate="false" />
<com:TTextBox id="text1" />
+
+ <com:TRequiredFieldValidator
+ ControlToValidate="text1"
+ ErrorMessage="*" />
+
<com:TActiveLabel id="label2" />
<com:TActivePanel id="panel1" >
@@ -24,7 +24,9 @@
<com:TButton id="button1" Text="Submit 1 (3s delay)" CausesValidation="false" />
- <com:TButton id="button2" Text="Submit 2" CausesValidation="false" />
+
+ <com:TActiveButton id="button2" Text="Submit 2" OnClick="onButtonClicked" OnCallback="fastResponse" />
+
<script>
Event.observe("<%= $this->button1->ClientID %>", "click", function(event)
{
@@ -32,12 +34,6 @@
Event.stop(event);
});
- Event.observe("<%= $this->button2->ClientID %>", "click", function(event)
- {
- <%= $this->control2->CallbackReference %>
-
- Event.stop(event);
- });
-
+
</script>
</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php
index ace6291b..47bab3cc 100644
--- a/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php
+++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php
@@ -9,7 +9,7 @@ class ActiveControl extends TPage
public function slowResponse($sender, $param)
{
- sleep(3);
+ sleep(1);
$this->label1->setText("The time is ".time()." from ".$sender->ID);
$this->label1->setForeColor($this->getColor());
$this->label1->renderControl($param->getOutput());
@@ -20,9 +20,13 @@ class ActiveControl extends TPage
$this->getCallbackClient()->shake($this->panel1);
}
- public function fastResponse($sender, $param)
+ public function onButtonClicked($sender, $param)
{
$this->label2->setText("Muahaha !!! the time is ".time()." from ".$sender->ID);
+ }
+
+ public function fastResponse($sender, $param)
+ {
$style['color'] = $this->getColor();
$this->getCallbackClient()->setStyle($this->label2, $style);
$this->getCallbackClient()->shake($this->label2);
diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.page b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.page
new file mode 100644
index 00000000..e3dcb707
--- /dev/null
+++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.page
@@ -0,0 +1,29 @@
+<com:TContent ID="Content">
+ <h1>Callback Enabled Calculator</h1>
+
+ <com:TActiveTextBox id="a" />
+ +
+ <com:TActiveTextBox id="b" />
+ =
+ <com:TActiveTextBox id="c" />
+
+ <com:TActiveButton id="sum" onclick="do_sum" text="Calculate!" />
+
+ <com:TRequiredFieldValidator
+ ControlToValidate="a"
+ ErrorMessage="left summand is required."
+ ControlCssClass="required"
+ Display="None" />
+ <com:TRequiredFieldValidator
+ ControlToValidate="b"
+ ErrorMessage="right summand is requied."
+ ControlCssClass="required"
+ Display="None" />
+
+ <div class="summarybox">
+ <com:TValidationSummary
+ ID="summary"
+ HeaderText="Unable to calculate because" />
+ </div>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php
new file mode 100644
index 00000000..bcf0f9cd
--- /dev/null
+++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php
@@ -0,0 +1,14 @@
+<?php
+/*
+ * Created on 6/05/2006
+ */
+
+class Calculator extends TPage
+{
+ public function do_sum($sender, $param)
+ {
+ $this->c->Text = floatval($this->a->Text) + floatval($this->b->Text);
+ }
+}
+
+?> \ No newline at end of file