diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2013-10-24 23:45:36 +0200 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2013-10-24 23:45:36 +0200 |
commit | a0ba7a2196cf4379c1772d36aeaf899b2cf47752 (patch) | |
tree | b02f1b8e30f0a79a4479b20b2f6a74fa0c2ccfca /framework/Web | |
parent | 695087b624283799fa9a150fceab0eff97bf9c68 (diff) |
More work on ajax
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js | 16 | ||||
-rw-r--r-- | framework/Web/Javascripts/source/prado/activecontrols/ajax3.js | 454 | ||||
-rw-r--r-- | framework/Web/Javascripts/source/prado/prado.js | 33 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveControlAdapter.php | 20 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveImageButton.php | 12 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveListBox.php | 6 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TCallbackClientScript.php | 5 | ||||
-rw-r--r-- | framework/Web/UI/TControl.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/TPage.php | 26 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 8 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRadioButton.php | 10 |
11 files changed, 175 insertions, 425 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index a586c4d9..8f1fd3b8 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -409,3 +409,19 @@ jQuery.extend(Prado.WebUI.TValueTriggeredCallback, Prado.WebUI.TActiveTableCell = jQuery.klass(Prado.WebUI.CallbackControl); Prado.WebUI.TActiveTableRow = jQuery.klass(Prado.WebUI.CallbackControl); + +Prado.WebUI.TActiveRatingList = jQuery.klass(Prado.WebUI.TRatingList, +{ + dispatchRequest : function(ev) + { + var requestOptions = jQuery.extend( + { + ID : this.options.ListID+"_c"+this.selectedIndex, + EventTarget : this.options.ListName+"$c"+this.selectedIndex + },this.options); + var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions); + if(request.dispatch()==false) + ev.stopPropagation(); + } + +}); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index 38bc4b7f..68b4a8be 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -47,10 +47,30 @@ Prado.CallbackRequestManager = /** * Hidden field list header name. */ - HIDDENFIELDLIST_HEADER : 'X-PRADO-HIDDENFIELDLIST' + HIDDENFIELDLIST_HEADER : 'X-PRADO-HIDDENFIELDLIST', + + /** + * Formats the exception message for display in console. + */ + 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; + } }; -Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { +Prado.CallbackRequest = jQuery.klass(Prado.PostBack, +{ options : {}, data : '', @@ -77,6 +97,14 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { this.options.onUninitialized(this,null); }, + /** + * Sets the request options + * @return {Array} request options. + */ + setOptions: function(options) { + jQuery.extend(this.options, options || { }); + }, + getForm: function() { return jQuery('#PRADO_PAGESTATE').get(0).form; @@ -187,9 +215,20 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { this.options.data = this.getParameters(); this.options.url = this.getCallbackUrl(); - jQuery.ajax(this.options); + this.request = jQuery.ajax(this.options); }, + abort : function() + { + if(this.request != "undefined") + this.request.abort(); + }, + + /** + * Collects the form inputs, encode the parameters, and sets the callback + * target id. The resulting string is the request content body. + * @return string request body content containing post data. + */ getParameters : function() { var form = this.getForm(); @@ -200,7 +239,10 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { if(this.options.EventTarget) data[Prado.CallbackRequestManager.FIELD_CALLBACK_TARGET] = this.options.EventTarget; - return jQuery(form).serialize() + '&' + jQuery.param(data); + if(this.options.PostInputs != false) + return jQuery(form).serialize() + '&' + jQuery.param(data); + else + return jQuery.param(data); }, /** @@ -226,12 +268,6 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { return this.data.substring(start,end); } return null; - /*var f = RegExp('(?:<!--'+boundary+'-->)((?:.|\n|\r)+?)(?:<!--//'+boundary+'-->)',"m"); - var result = this.data.match(f); - if(result && result.length >= 2) - return result[1]; - else - return null;*/ }, errorHandler: function(request, textStatus, errorThrown) @@ -239,24 +275,6 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { //null) are "timeout", "error", "abort", and "parsererror" if (this.options.onFailure) this.options.onFailure(this,null); - - if(request.status==500) - { - /** - * Server returns 500 exception. Just log it. - */ - var e = request.getResponseHeader(Prado.CallbackRequestManager.ERROR_HEADER); - if (e) - { - json = jQuery.parseJSON(e); - if(typeof(json) == "object") - Logger.error("Callback Server Error "+json.code, this.formatException(json)); - else - Logger.error("Callback Server Error Corrupted"); - } - else - Logger.error("Callback Server Error Unknown",''); - } }, completeHandler: function(request, textStatus) @@ -264,7 +282,6 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { //"success", "notmodified", "error", "timeout", "abort", or "parsererror" if (this.options.onComplete) this.options.onComplete(this,null); - }, /** @@ -284,25 +301,6 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { }, /** - * Formats the exception message for display in console. - */ - 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; - }, - - /** * Callback OnSuccess event,logs reponse and data to console. */ successHandler: function(data, textStatus, request) @@ -310,50 +308,21 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { if (this.options.onSuccess) this.options.onSuccess(this,null); - Logger.info('HTTP '+request.status+" with response : \n"+data); - this.data = data; var redirectUrl = this.extractContent(Prado.CallbackRequestManager.REDIRECT_HEADER); if (redirectUrl) document.location.href = redirectUrl; -/* - if ((this.getHeader('Content-type') || '').match(/^text\/javascript/i)) - { - try - { - json = eval('(' + transport.responseText + ')'); - } - catch (e) - { - if(typeof(json) == "string") - json = Prado.CallbackRequest.decode(result); - } - } -*/ - try - { + + try { this.updatePageState(this, data); this.checkHiddenFields(this, data); var obj = this; this.loadAssets(this, data, function() { - try - { - //Ajax.Responders.dispatch('on' + transport.status, obj, transport, json); + try { obj.dispatchActions(obj, data); -/* - ( - obj.options['on' + obj.transport.status] - || - obj.options['on' + (obj.success() ? 'Success' : 'Failure')] - || - Prototype.emptyFunction - ) (obj, json); - */ - } - catch (e) - { - obj.exceptionHandler(e); + } catch (e) { + obj.exceptionHandler(e); } } ); @@ -414,10 +383,13 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { json = jQuery.parseJSON(data); if(typeof(json) != "object") - Logger.warn("Invalid hidden field list:"+data); - else + { + if(typeof(Logger) != "undefined") + Logger.warn("Invalid hidden field list:"+data); + } else { for(var key in json) Prado.CallbackRequestManager.checkHiddenField(key,json[key]); + } } }, @@ -464,8 +436,10 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { json = jQuery.parseJSON(data); if(typeof(json) != "object") - Logger.warn("Invalid script list:"+data); - else + { + if(typeof(Logger) != "undefined") + Logger.warn("Invalid script list:"+data); + } else { for(var key in json) if (/^\d+$/.test(key)) { @@ -473,6 +447,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { if (!Prado.ScriptManager.isAssetLoaded(url)) this.ScriptsToLoad.push(url); } + } } this.loadNextScript(); }, @@ -510,11 +485,14 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { json = jQuery.parseJSON(data); if(typeof(json) != "object") - Logger.warn("Invalid stylesheet list:"+data); - else + { + if(typeof(Logger) != "undefined") + Logger.warn("Invalid stylesheet list:"+data); + } else { for(var key in json) if (/^\d+$/.test(key)) Prado.StyleSheetManager.createStyleSheetCode(json[key],null); + } } }, @@ -525,11 +503,14 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { json = jQuery.parseJSON(data); if(typeof(json) != "object") - Logger.warn("Invalid stylesheet list:"+data); - else + { + if(typeof(Logger) != "undefined") + Logger.warn("Invalid stylesheet list:"+data); + } else { for(var key in json) if (/^\d+$/.test(key)) Prado.StyleSheetManager.ensureAssetIsLoaded(json[key],null); + } } }, @@ -542,8 +523,10 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { json = jQuery.parseJSON(data); if(typeof(json) != "object") - Logger.warn("Invalid stylesheet list:"+data); - else + { + if(typeof(Logger) != "undefined") + Logger.warn("Invalid stylesheet list:"+data); + } else { for(var key in json) if (/^\d+$/.test(key)) { @@ -551,6 +534,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { if (!Prado.StyleSheetManager.isAssetLoaded(url)) this.StyleSheetsToLoad.push(url); } + } } this.loadNextStyleSheet(); }, @@ -569,9 +553,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { ) ) this.loadNextStyleSheet(); - } - else - { + } else { if (this.StyleSheetLoadFinishedCallback) { var cb = this.StyleSheetLoadFinishedCallback; @@ -591,10 +573,13 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { json = jQuery.parseJSON(data); if(typeof(json) != "object") - Logger.warn("Invalid action:"+data); - else + { + if(typeof(Logger) != "undefined") + Logger.warn("Invalid action:"+data); + } else { for(var key in json) this.__run(this, json[key]); + } } }, @@ -605,107 +590,63 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { { for(var method in command) { - try - { + try { method.toFunction().apply(request,command[method]); - } - catch(e) - { - if(typeof(Logger) != "undefined") - this.Exception.exceptionHandler(null,e); - else - debugger; + } catch(e) { + this.exceptionHandler(null,e); } } }, }); -Prado.CallbackRequest.addPostLoaders = function(ids) +//Add HTTP exception respones when logger is enabled. +jQuery(function() { - //dummy -}; - - - -// Prado.AjaxRequest = jQuery.klass(); -// Prado.AjaxRequest.prototype = { -// * Customize the response, dispatch onXXX response code events, and -// * tries to execute response actions (javascript statements). -// */ -// respondToReadyState : function(readyState) -// { -// var event = Ajax.Request.Events[readyState]; -// var transport = this.transport, json = this.getBodyDataPart(Prado.CallbackRequest.DATA_HEADER); - -// if (event == 'Complete') -// { - -// } - -// /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ -// if (event == 'Complete') -// this.transport.onreadystatechange = Prototype.emptyFunction; -// }, - -// /** -// * Gets header data assuming JSON encoding. -// * @param string header name -// * @return object header data as javascript structures. -// */ -// getHeaderData : function(name) -// { -// return this.getJsonData(this.getHeader(name)); -// }, + if(typeof Logger != "undefined") + { + jQuery( document ).ajaxSuccess(function( event, request, settings ) { + Logger.info('HTTP '+request.status+" with response : \n"); -// getJsonData : function(json) -// { -// try -// { -// return eval('(' + json + ')'); -// } -// catch (e) -// { -// if(typeof(json) == "string") -// return Prado.CallbackRequest.decode(json); -// } -// }, + var tagStart = '<!--'; + var tagEnd = '<!--//'; + var start = request.responseText.indexOf(tagStart); + while(start > -1) + { + var end = request.responseText.indexOf(tagEnd,start); + if(end > -1) + Logger.info(request.responseText.substring(start,end)+'\n'); + start = request.responseText.indexOf(tagStart,end+6); + } + }); -// getBodyDataPart : function(name) -// { -// return this.getJsonData(this.getBodyContentPart(name)); -// } -// }; + jQuery( document ).ajaxError(function( event, request, settings, exception ) { + if(request.status==500) + { + /** + * Server returns 500 exception. Just log it. + */ + var e = request.getResponseHeader(Prado.CallbackRequestManager.ERROR_HEADER); + if (e) + { + json = jQuery.parseJSON(e); + if(typeof(json) == "object") + Logger.error("Callback Server Error "+json.code, Prado.CallbackRequestManager.formatException(json)); + else + Logger.error("Callback Server Error Corrupted"); + } else { + Logger.error("Callback Server Error Unknown",''); + } + } + }); + } +}); // /** // * Prado Callback client-side request handler. // */ // Prado.CallbackRequestManager = // { -// /** -// * Callback request target POST field name. -// */ -// FIELD_CALLBACK_TARGET : 'PRADO_CALLBACK_TARGET', -// /** -// * Callback request parameter POST field name. -// */ -// FIELD_CALLBACK_PARAMETER : 'PRADO_CALLBACK_PARAMETER', -// /** -// * Callback request page state field name, -// */ -// FIELD_CALLBACK_PAGESTATE : 'PRADO_PAGESTATE', - -// FIELD_POSTBACK_TARGET : 'PRADO_POSTBACK_TARGET', - -// FIELD_POSTBACK_PARAMETER : 'PRADO_POSTBACK_PARAMETER', - -// /** -// * List of form fields that will be collected during callback. -// */ -// PostDataLoaders : [], - - - // requestQueue : [], @@ -727,22 +668,6 @@ Prado.CallbackRequest.addPostLoaders = function(ids) // }, // /** -// * Add ids of inputs element to post in the request. -// */ -// addPostLoaders : function(ids) -// { -// var self = Prado.CallbackRequest; -// self.PostDataLoaders = self.PostDataLoaders.concat(ids); -// var list = []; -// self.PostDataLoaders.each(function(id) -// { -// if(list.indexOf(id) < 0) -// list.push(id); -// }); -// self.PostDataLoaders = list; -// }, - -// /** // * Dispatch a normal request, no timeouts or aborting of requests. // */ // dispatchNormalRequest : function(callback) @@ -837,14 +762,6 @@ Prado.CallbackRequest.addPostLoaders = function(ids) // } // }}); // */ -// //Add HTTP exception respones when logger is enabled. -// /* -// Event.OnLoad(function() -// { -// if(typeof Logger != "undefined") -// Ajax.Responders.register(Prado.CallbackRequest.Exception); -// }); -// */ // /** // * Create and prepare a new callback request. @@ -861,12 +778,6 @@ Prado.CallbackRequest.addPostLoaders = function(ids) // */ // initialize : function(id, options) // { -// /** -// * Callback URL, same url as the current page. -// */ -// this.url = this.getCallbackUrl(); - -// //this.transport = Ajax.getTransport(); // this.Enabled = true; // this.id = id; // this.randomId = this.randomString(); @@ -875,92 +786,8 @@ Prado.CallbackRequest.addPostLoaders = function(ids) // Prado.CallbackRequestManager.requests[id+"__"+this.randomId] = this; // } -// this.setOptions(jQuery.extend( -// { -// RequestTimeOut : 30000, // 30 second timeout. -// EnablePageStateUpdate : true, -// HasPriority : true, -// CausesValidation : true, -// ValidationGroup : null, -// PostInputs : true -// }, options || {})); - -// this.ActiveControl = this.options; // Prado.CallbackRequestManager.requests[id+"__"+this.randomId].ActiveControl = this.options; // }, - -// /** -// * Sets the request options -// * @return {Array} request options. -// */ -// setOptions: function(options){ - -// this.options = { -// method: 'post', -// asynchronous: true, -// contentType: 'application/x-www-form-urlencoded', -// encoding: 'UTF-8', -// parameters: '', -// evalJSON: true, -// evalJS: true -// }; - -// jQuery.extend(this.options, options || { }); - -// this.options.method = this.options.method.toLowerCase(); -// if(jQuery.type(this.options.parameters) === "string") { -// //this.options.parameters = this.options.parameters.toQueryParams(); -// } -// }, - -// abort : function() -// { -// return Prado.CallbackRequestManager.abortRequest(this.id); -// }, - -// /** -// * Collects the form inputs, encode the parameters, and sets the callback -// * target id. The resulting string is the request content body. -// * @return string request body content containing post data. -// */ -// _getPostData : function() -// { -// var data = {}; -// var callback = Prado.CallbackRequest; -// if(this.ActiveControl.PostInputs != false) -// { -// callback.PostDataLoaders.each(function(name) -// { -// var elements=$A(document.getElementsByName(name)); -// if(elements.size() == 0) -// { -// name += '[]'; -// elements=$A(document.getElementsByName(name)); -// } -// elements.each(function(element) -// { -// //IE will try to get elements with ID == name as well. -// if(element.type && element.name == name) -// { -// var value = $F(element); -// if(typeof(value) != "undefined" && value != null) -// data[name] = value; -// } -// }) -// }) -// } -// if(typeof(this.ActiveControl.CallbackParameter) != "undefined") -// data[callback.FIELD_CALLBACK_PARAMETER] = callback.encode(this.getCallbackParameter()); -// var pageState = $F(callback.FIELD_CALLBACK_PAGESTATE); -// if(typeof(pageState) != "undefined") -// data[callback.FIELD_CALLBACK_PAGESTATE] = pageState; -// data[callback.FIELD_CALLBACK_TARGET] = this.id; -// if(this.ActiveControl.EventTarget) -// data[callback.FIELD_POSTBACK_TARGET] = this.ActiveControl.EventTarget; -// if(this.ActiveControl.EventParameter) -// data[callback.FIELD_POSTBACK_PARAMETER] = this.ActiveControl.EventParameter; -// return $H(data).toQueryString(); -// }, // /** // * Creates a random string with a length of 8 chars. @@ -1129,10 +956,10 @@ if (typeof(Prado.AssetManagerClass)=="undefined") { ensureAssetIsLoaded: function(url, callback) { url = this.makeFullUrl(url); if (this.loadedAssets.indexOf(url)==-1) - { - this.startAssetLoad(url,callback); - return false; - } + { + this.startAssetLoad(url,callback); + return false; + } else return true; } @@ -1156,10 +983,10 @@ Prado.ScriptManagerClass = jQuery.klass(Prado.AssetManagerClass, { }, createAssetElement: function(url) { - var asset = document.createElement('script'); - asset.type = 'text/javascript'; - asset.src = url; - // asset.async = false; // HTML5 only + var asset = document.createElement('script'); + asset.type = 'text/javascript'; + asset.src = url; + // asset.async = false; // HTML5 only return asset; } @@ -1180,22 +1007,22 @@ Prado.StyleSheetManagerClass = jQuery.klass(Prado.AssetManagerClass, { }, createAssetElement: function(url) { - var asset = document.createElement('link'); - asset.rel = 'stylesheet'; - asset.media = 'screen'; - asset.setAttribute('type', 'text/css'); - asset.href = url; - // asset.async = false; // HTML5 only + var asset = document.createElement('link'); + asset.rel = 'stylesheet'; + asset.media = 'screen'; + asset.setAttribute('type', 'text/css'); + asset.href = url; + // asset.async = false; // HTML5 only return asset; }, createStyleSheetCode: function(code) { - var asset = document.createElement('style'); - asset.setAttribute('type', 'text/css'); + var asset = document.createElement('style'); + asset.setAttribute('type', 'text/css'); asset.innerText = code; var head = document.getElementsByTagName('head')[0]; - head.appendChild(asset); + head.appendChild(asset); } }); @@ -1210,4 +1037,3 @@ var discover = function() { } if (window.attachEvent) window.attachEvent('onload', discover); else if (window.addEventListener) window.addEventListener('load', discover, false); - diff --git a/framework/Web/Javascripts/source/prado/prado.js b/framework/Web/Javascripts/source/prado/prado.js index e1e672ff..c850edb1 100644 --- a/framework/Web/Javascripts/source/prado/prado.js +++ b/framework/Web/Javascripts/source/prado/prado.js @@ -52,19 +52,6 @@ Prado.PostBack = jQuery.klass( return jQuery("#" + this.options['FormID']).get(0); }, - getParameters : function() - { - var form = this.getForm(); - var data = {}; - - if(this.options.EventTarget) - data[Prado.RequestManager.FIELD_POSTBACK_TARGET] = this.options.EventTarget; - if(this.options.EventParameter) - data[Prado.RequestManager.FIELD_POSTBACK_PARAMETER] = this.options.EventParameter; - - return jQuery(form).serialize() + '&' + jQuery.param(data); - }, - doPostBack : function() { var form = this.getForm(); @@ -90,7 +77,25 @@ Prado.PostBack = jQuery.klass( } } - $(form).trigger('submit'); + var input=null; + if(this.options.EventTarget) + { + input = document.createElement("input"); + input.setAttribute("type", "hidden"); + input.setAttribute("name", Prado.RequestManager.FIELD_POSTBACK_TARGET); + input.setAttribute("value", this.options.EventTarget); + form.appendChild(input); + } + if(this.options.EventParameter) + { + input = document.createElement("input"); + input.setAttribute("type", "hidden"); + input.setAttribute("name", Prado.RequestManager.FIELD_POSTBACK_PARAMETER); + input.setAttribute("value", this.options.EventParameter); + form.appendChild(input); + } + + jQuery(form).trigger('submit'); } }); diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php index ab15f091..6c209ac5 100644 --- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php @@ -89,7 +89,6 @@ class TActiveControlAdapter extends TControlAdapter public function render($writer) { $this->getPage()->getClientScript()->registerPradoScript('ajax'); - $this->renderCallbackClientScripts(); if($this->_control->getVisible(false)) { parent::render($writer); @@ -99,25 +98,6 @@ class TActiveControlAdapter extends TControlAdapter } /** - * Register the callback clientscripts and sets the post loader IDs. - */ - protected function renderCallbackClientScripts() - { - $cs = $this->getPage()->getClientScript(); - $key = 'Prado.CallbackRequest.addPostLoaders'; - if(!$cs->isEndScriptRegistered($key)) - { - $data = $this->getPage()->getPostDataLoaders(); - if(count($data) > 0) - { - $options = TJavaScript::encode($data,false); - $script = "Prado.CallbackRequest.addPostLoaders({$options});"; - $cs->registerEndScript($key, $script); - } - } - } - - /** * @param TBaseActiveControl change base active control */ public function setBaseActiveControl($control) diff --git a/framework/Web/UI/ActiveControls/TActiveImageButton.php b/framework/Web/UI/ActiveControls/TActiveImageButton.php index b2aa9960..8fe5e33d 100644 --- a/framework/Web/UI/ActiveControls/TActiveImageButton.php +++ b/framework/Web/UI/ActiveControls/TActiveImageButton.php @@ -135,18 +135,6 @@ class TActiveImageButton extends TImageButton implements IActiveControl, ICallba } /** - * Register the x and y hidden input names of the position clicked. - * @param THtmlWriter the renderer. - */ - public function onPreRender($writer) - { - parent::onPreRender($writer); - $uid = $uid=$this->getUniqueID(); - $this->getPage()->registerPostDataLoader($uid.'_x'); - $this->getPage()->registerPostDataLoader($uid.'_y'); - } - - /** * Ensure that the ID attribute is rendered and registers the javascript code * for initializing the active control. */ diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php index dfb4bf6e..913cdeda 100644 --- a/framework/Web/UI/ActiveControls/TActiveListBox.php +++ b/framework/Web/UI/ActiveControls/TActiveListBox.php @@ -95,8 +95,6 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH $client = $this->getPage()->getCallbackClient(); $client->setAttribute($this, 'multiple', $multiple ? 'multiple' : false); $client->setAttribute($this, 'name', $multiple ? $multi_id : $id); - if($multiple) - $client->addPostDataLoader($multi_id); } } @@ -130,10 +128,6 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH { parent::onPreRender($param); $this->getAdapter()->updateListItems(); - $multiple = $this->getIsMultiSelect(); - $id = $this->getUniqueID(); $multi_id = $id.'[]'; - if($multiple) - $this->getPage()->registerPostDataLoader($multi_id); } /** diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 15300727..a25e7f41 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -304,11 +304,6 @@ class TCallbackClientScript extends TApplicationComponent $this->jQuery($element, 'remove'); } - public function addPostDataLoader($name) - { - $this->callClientFunction('Prado.CallbackRequest.addPostLoaders', $name); - } - /** * Update the element's innerHTML with new content. * @param TControl control element or element id diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 5ee20d61..cbc6a409 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1330,21 +1330,11 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable $control->evaluateDynamicContent(); } } - $this->addToPostDataLoader(); } $this->_stage=self::CS_PRERENDERED; } /** - * Add controls implementing IPostBackDataHandler to post data loaders. - */ - protected function addToPostDataLoader() - { - if($this instanceof IPostBackDataHandler) - $this->getPage()->registerPostDataLoader($this); - } - - /** * Performs the Unload step for the control and all its child controls. * Only framework developers should use this method. */ diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 39656e13..4e8652f4 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -155,10 +155,6 @@ class TPage extends TTemplateControl */ private $_clientState=''; /** - * @var array post data loader IDs. - */ - protected $_postDataLoaders=array(); - /** * @var boolean true if loading post data. */ protected $_isLoadingPostData=false; @@ -427,27 +423,6 @@ class TPage extends TTemplateControl } /** - * Register post data loaders for Callback to collect post data. - * This method should only be called by framework developers. - * @param TControl control that requires post data. - * @see TControl::preRenderRecursive(); - */ - public function registerPostDataLoader($control) - { - $id=is_string($control)?$control:$control->getUniqueID(); - $this->_postDataLoaders[$id] = true; - } - - /** - * Get a list of IDs of controls that are enabled and require post data. - * @return array list of IDs implementing IPostBackDataHandler - */ - public function getPostDataLoaders() - { - return array_keys($this->_postDataLoaders); - } - - /** * @return TForm the form on the page */ public function getForm() @@ -825,7 +800,6 @@ class TPage extends TTemplateControl { $id=is_string($control)?$control:$control->getUniqueID(); $this->_controlsRegisteredForPostData[$id]=true; - $this->registerPostDataLoader($id); $params=func_get_args(); foreach($this->getCachingStack() as $item) $item->registerAction('Page','registerRequiresPostData',array($id)); diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index a67997b8..b5ed8a86 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -406,14 +406,6 @@ class TDatePicker extends TTextBox public function onPreRender($param) { parent::onPreRender($param); - if($this->getInputMode() === TDatePickerInputMode::DropDownList) - { - $page = $this->getPage(); - $uniqueID = $this->getUniqueID(); - $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'day'); - $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'month'); - $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'year'); - } $this->publishCalendarStyle(); $this->registerCalendarClientScriptPre(); } diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 144704b4..dbb0dac0 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -156,16 +156,6 @@ class TRadioButton extends TCheckBox } /** - * Add the group name as post data loader if group name is set. - */ - protected function addToPostDataLoader() - { - parent::addToPostDataLoader(); - $group = $this->getGroupName(); - if(!empty($group) || $this->getViewState('UniqueGroupName','') !== '') - $this->getPage()->registerPostDataLoader($this->getUniqueGroupName()); - } - /** * @return string the name used to fetch radiobutton post data */ public function getUniqueGroupName() |