From 6dd529fdc25404da07cf9256d92f2a94985c65fc Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 11 Aug 2006 06:55:09 +0000 Subject: Update callback request client-side API. --- framework/Web/Javascripts/js/ajax.js | 26 ++- framework/Web/Javascripts/prado/activecontrols.js | 196 --------------------- framework/Web/Javascripts/prado/activecontrols3.js | 72 ++++---- framework/Web/Javascripts/prado/ajax3.js | 176 ++++++++++++------ .../Web/UI/ActiveControls/TBaseActiveControl.php | 15 +- 5 files changed, 193 insertions(+), 292 deletions(-) delete mode 100644 framework/Web/Javascripts/prado/activecontrols.js (limited to 'framework') diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js index 40a27f00..fd1b7a76 100644 --- a/framework/Web/Javascripts/js/ajax.js +++ b/framework/Web/Javascripts/js/ajax.js @@ -75,8 +75,16 @@ Ajax.Responders.register({onComplete:function(request) 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} -Object.extend(this.options,options||{});Object.extend(this.options,{postBody:this._getPostData(),parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined") +{this.id=id;this.options=Object.extend({RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true},options||{});},setParameter:function(value) +{this.options['params']=value;},getParameter:function() +{return this.options['params'];},setRequestTimeOut:function(timeout) +{this.options['RequestTimeOut']=timeout;},getRequestTimeOut:function() +{return this.options['RequestTimeOut'];},setCausesValidation:function(validate) +{this.options['CausesValidation']=validate;},getCausesValidation:function() +{return this.options['CausesValidation'];},setValidationGroup:function(group) +{this.options['ValidationGroup']=group;},getValidationGroup:function() +{return this.options['ValidationGroup'];},dispatch:function() +{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) @@ -93,7 +101,7 @@ data[callback.FIELD_CALLBACK_PAGESTATE]=pageState;data[callback.FIELD_CALLBACK_T data[callback.FIELD_POSTBACK_TARGET]=this.options.EventTarget;if(this.options.EventParameter) data[callback.FIELD_POSTBACK_PARAMETER]=this.options.EventParameter;return $H(data).toQueryString();}} Prado.Callback=function(UniqueID,parameter,onSuccess,options) -{var callback={'params':parameter||'','onSuccess':onSuccess||Prototype.emptyFunction};Object.extend(callback,options||{});new Prado.CallbackRequest(UniqueID,callback);return false;} +{var callback={'params':parameter||'','onSuccess':onSuccess||Prototype.emptyFunction};Object.extend(callback,options||{});request=new Prado.CallbackRequest(UniqueID,callback);request.dispatch();return false;} Array.prototype.______array='______array';Prado.JSON={org:'http://www.JSON.org',copyright:'(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(arg){var c,i,l,s='',v;switch(typeof arg){case'object':if(arg){if(arg.______array=='______array'){for(i=0;i0) @@ -206,7 +214,7 @@ this.updateChoices(result);}});Prado.WebUI.TCallbackTimer=Base.extend({count:0,t this.onComplete=this.options.onComplete;Prado.WebUI.TCallbackTimer.register(this);},startTimer:function() {this.options.onComplete=this.onRequestComplete.bind(this);setTimeout(this.onTimerEvent.bind(this),200);},stopTimer:function() {(this.onComplete||Prototype.emptyFunction).apply(this,arguments);this.options.onComplete=undefined;clearTimeout(this.timer);this.timer=undefined;this.count=0;},onTimerEvent:function() -{this.options.params=this.timeout/1000;new Prado.CallbackRequest(this.options.ID,this.options);},onRequestComplete:function() +{this.options.params=this.timeout/1000;request=new Prado.CallbackRequest(this.options.ID,this.options);request.dispatch();},onRequestComplete:function() {(this.onComplete||Prototype.emptyFunction).apply(this,arguments);this.timer=setTimeout(this.onTimerEvent.bind(this),this.getNewTimeout())},getNewTimeout:function() {switch(this.options.DecayType) {case'Exponential':t=(Math.exp(this.options.DecayRate*this.count*this.options.Interval))-1;break;case'Linear':t=this.options.DecayRate*this.count*this.options.Interval;break;case'Quadratic':t=this.options.DecayRate*this.count*this.count*this.options.Interval;break;case'Cubic':t=this.options.DecayRate*this.count*this.count*this.count*this.options.Interval;break;default:t=0;} @@ -217,4 +225,4 @@ this.timers[id].startTimer();},stop:function(id) {if(this.timers[id]) this.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options) {this.element=$(options.ID);this.options=options;Event.observe(this.element,"change",this.doCallback.bind(this));},doCallback:function(event) -{new Prado.CallbackRequest(this.options.EventTarget,this.options);Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl; \ No newline at end of file +{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl; \ No newline at end of file diff --git a/framework/Web/Javascripts/prado/activecontrols.js b/framework/Web/Javascripts/prado/activecontrols.js deleted file mode 100644 index 72f97511..00000000 --- a/framework/Web/Javascripts/prado/activecontrols.js +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Auto complete textbox via AJAX. - */ -Prado.AutoCompleter = Class.create(); - - -/** - * Overrides parent implementation of updateElement by trimming the value. - */ -Prado.AutoCompleter.Base = function(){}; -Prado.AutoCompleter.Base.prototype = Object.extend(Autocompleter.Base.prototype, -{ - updateElement: function(selectedElement) - { - if (this.options.updateElement) { - this.options.updateElement(selectedElement); - return; - } - - var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - var lastTokenPos = this.findLastToken(); - if (lastTokenPos != -1) { - var newValue = this.element.value.substr(0, lastTokenPos + 1); - var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); - if (whitespace) - newValue += whitespace[0]; - this.element.value = (newValue + value).trim(); - } else { - this.element.value = value.trim(); - } - this.element.focus(); - - if (this.options.afterUpdateElement) - this.options.afterUpdateElement(this.element, selectedElement); - } -}); - -/** - * Based on the Prototype Autocompleter class. - * This client-side component should be instantiated from a Prado component. - * Usage: new Prado.AutoCompleter('textboxID', 'updateDivID', {callbackID : '...'}); - */ -Prado.AutoCompleter.prototype = Object.extend(new Autocompleter.Base(), -{ - /** - * This component is initialized by - * new Prado.AutoCompleter(...) - * @param string the ID of the textbox element to observe - * @param string the ID of the div to display the auto-complete options - * @param array a hash of options, e.g. auto-completion token separator. - */ - initialize : function(element, update, options) - { - this.baseInitialize(element, update, options); - }, - - /** - * The callback function, i.e., function called on successful AJAX return. - * Calls update choices in the Autocompleter. - * @param string new auto-complete options for display - */ - onUpdateReturn : function(result) - { - if(isString(result) && result.length > 0) - this.updateChoices(result); - }, - - /** - * Requesting new choices using Prado's client-side callback scheme. - */ - getUpdatedChoices : function() - { - Prado.Callback(this.element.id, this.getToken(), this.onUpdateReturn.bind(this)); - } -}); - -/** - * Prado TActivePanel client javascript. Usage - * - * Prado.ActivePanel.register("id", options); - * Prado.ActivePanel.update("id", "hello"); - * - */ -Prado.ActivePanel = -{ - callbacks : {}, - - register : function(id, options) - { - Prado.ActivePanel.callbacks[id] = options; - }, - - update : function(id, param) - { - var request = new Prado.ActivePanel.Request(id, - Prado.ActivePanel.callbacks[id]); - request.callback(param); - } -} - -/** - * Client-script for TActivePanel. Uses Callback to notify the server - * for updates, if update option is set, the innerHTML of the update ID - * is set to the returned output. - */ -Prado.ActivePanel.Request = Class.create(); -Prado.ActivePanel.Request.prototype = -{ - initialize : function(element, options) - { - this.element = element; - this.setOptions(options); - }, - - /** - * Set some options. - */ - setOptions : function(options) - { - this.options = - { - onSuccess : this.onSuccess.bind(this) - } - Object.extend(this.options, options || {}); - }, - - /** - * Make the callback request - */ - callback : function(param) - { - this.options.params = [param]; - new Prado.AJAX.Callback(this.element, this.options); - }, - - /** - * Callback onSuccess handler, update the element innerHTML if necessary - */ - onSuccess : function(result, output) - { - if(this.options.update) - { - if (!this.options.evalScripts) - output = output.stripScripts(); - Element.update(this.options.update, output); - } - } -} - -/** - * Drop container to accept draggable component drops. - */ -Prado.DropContainer = Class.create(); -Prado.DropContainer.prototype = Object.extend(new Prado.ActivePanel.Request(), -{ - initialize : function(element, options) - { - this.element = element; - this.setOptions(options); - Object.extend(this.options, - { - onDrop : this.onDrop.bind(this), - evalScripts : true, - onSuccess : options.onSuccess || this.onSuccess.bind(this) - }); - Droppables.add(element, this.options); - }, - - onDrop : function(draggable, droppable) - { - this.callback(draggable.id) - } -}); - -Prado.ActiveImageButton = Class.create(); -Prado.ActiveImageButton.prototype = -{ - initialize : function(element, options) - { - this.element = $(element); - this.options = options; - Event.observe(this.element, "click", this.click.bind(this)); - }, - - click : function(e) - { - var el = $('{$this->ClientID}'); - var imagePos = Position.cumulativeOffset(this.element); - var clickedPos = [e.clientX, e.clientY]; - var param = (clickedPos[0]-imagePos[0]+1)+","+(clickedPos[1]-imagePos[1]+1); - Prado.Callback(this.element, param, null, this.options); - Event.stop(e); - } -} - - diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js index fc3af2a8..71719f35 100644 --- a/framework/Web/Javascripts/prado/activecontrols3.js +++ b/framework/Web/Javascripts/prado/activecontrols3.js @@ -5,9 +5,10 @@ Prado.WebUI.CallbackControl = Class.extend(Prado.WebUI.PostBackControl, { onPostBack : function(event, options) { - new Prado.CallbackRequest(options.EventTarget, options); + request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); Event.stop(event); - } + } }); /** @@ -15,15 +16,16 @@ Prado.WebUI.CallbackControl = Class.extend(Prado.WebUI.PostBackControl, */ Prado.WebUI.TActiveButton = Class.extend(Prado.WebUI.CallbackControl); -/** +/** * Active check box. */ Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl, { onPostBack : function(event, options) { - new Prado.CallbackRequest(options.EventTarget, options); - } + request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); + } }); /** @@ -37,10 +39,11 @@ Prado.WebUI.TActiveTextBox = Class.extend(Prado.WebUI.TTextBox, Event.observe(this.element, "keydown", this.handleReturnKey.bind(this)); Event.observe(this.element, "change", this.doCallback.bindEvent(this,options)); }, - + doCallback : function(event, options) { - new Prado.CallbackRequest(options.EventTarget, options); + request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); Event.stop(event); } }); @@ -55,11 +58,11 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, { this.options = options; this.baseInitialize(options.ID, options.ResultPanel, options); - Object.extend(this.options, + Object.extend(this.options, { onSuccess : this.onComplete.bind(this) }); - + if(options.AutoPostBack) this.onInit(options); }, @@ -68,13 +71,14 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, { if(!this.active) { - new Prado.CallbackRequest(options.EventTarget, options); + request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); Event.stop(event); } }, - + //Overrides parent implementation, fires onchange event. - onClick: function(event) + onClick: function(event) { var element = Event.findElement(event, 'LI'); this.index = element.autocompleteIndex; @@ -82,29 +86,29 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, this.hide(); Event.fireEvent(this.element, "change"); }, - + getUpdatedChoices : function() { options = new Array(this.getToken(),"__TAutoComplete_onSuggest__"); Prado.Callback(this.options.EventTarget, options, null, this.options); }, - - onComplete : function(request, boundary) + + onComplete : function(request, boundary) { result = Prado.Element.extractContent(request.responseText, boundary); if(typeof(result) == "string" && result.length > 0) this.updateChoices(result); - } + } }); -/** - * Callback Timer class. +/** + * Callback Timer class. */ Prado.WebUI.TCallbackTimer = Base.extend( { count : 0, timeout : 0, - + constructor : function(options) { this.options = Object.extend( @@ -112,17 +116,17 @@ Prado.WebUI.TCallbackTimer = Base.extend( Interval : 1, DecayRate : 0 }, options || {}) - + this.onComplete = this.options.onComplete; Prado.WebUI.TCallbackTimer.register(this); }, - + startTimer : function() { this.options.onComplete = this.onRequestComplete.bind(this); setTimeout(this.onTimerEvent.bind(this), 200); }, - + stopTimer : function() { (this.onComplete || Prototype.emptyFunction).apply(this, arguments); @@ -131,19 +135,20 @@ Prado.WebUI.TCallbackTimer = Base.extend( this.timer = undefined; this.count = 0; }, - + onTimerEvent : function() { this.options.params = this.timeout/1000; - new Prado.CallbackRequest(this.options.ID, this.options); + request = new Prado.CallbackRequest(this.options.ID, this.options); + request.dispatch(); }, - + onRequestComplete : function() { (this.onComplete || Prototype.emptyFunction).apply(this, arguments); this.timer = setTimeout(this.onTimerEvent.bind(this), this.getNewTimeout()) }, - + getNewTimeout : function() { switch(this.options.DecayType) @@ -170,18 +175,18 @@ Prado.WebUI.TCallbackTimer = Base.extend( //class methods { timers : {}, - + register : function(timer) { this.timers[timer.options.ID] = timer; }, - + start : function(id) { if(this.timers[id]) this.timers[id].startTimer(); - }, - + }, + stop : function(id) { if(this.timers[id]) @@ -195,12 +200,13 @@ Prado.WebUI.ActiveListControl = Base.extend( { this.element = $(options.ID); this.options = options; - Event.observe(this.element, "change", this.doCallback.bind(this)); + Event.observe(this.element, "change", this.doCallback.bind(this)); }, - + doCallback : function(event) { - new Prado.CallbackRequest(this.options.EventTarget, this.options); + request = new Prado.CallbackRequest(this.options.EventTarget, this.options); + request.dispatch(); Event.stop(event); } }); diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js index bae60d89..8de0b0fe 100644 --- a/framework/Web/Javascripts/prado/ajax3.js +++ b/framework/Web/Javascripts/prado/ajax3.js @@ -7,14 +7,14 @@ Object.extend(Ajax.Request.prototype, * Customize the response, dispatch onXXX response code events, and * tries to execute response actions (javascript statements). */ - respondToReadyState : function(readyState) + respondToReadyState : function(readyState) { var event = Ajax.Request.Events[readyState]; var transport = this.transport, json = this.getHeaderData(Prado.CallbackRequest.DATA_HEADER); - if (event == 'Complete') - { - try + if (event == 'Complete') + { + try { Prado.CallbackRequest.updatePageState(this,transport); Ajax.Responders.dispatch('on' + transport.status, this, transport, json); @@ -29,19 +29,19 @@ Object.extend(Ajax.Request.prototype, if ((this.header('Content-type') || '').match(/^text\/javascript/i)) this.evalResponse(); } - + try { (this.options['on' + event] || Prototype.emptyFunction)(transport, json); Ajax.Responders.dispatch('on' + event, this, transport, json); } catch (e) { this.dispatchException(e); } - + /* 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 @@ -49,12 +49,12 @@ Object.extend(Ajax.Request.prototype, */ getHeaderData : function(name) { - try + try { var json = this.header(name); return eval('(' + json + ')'); - } - catch (e) + } + catch (e) { if(typeof(json) == "string") return Prado.CallbackRequest.decode(json); @@ -84,9 +84,9 @@ Object.extend(Prado.CallbackRequest, * Callback request page state field name, */ FIELD_CALLBACK_PAGESTATE : 'PRADO_PAGESTATE', - + FIELD_POSTBACK_TARGET : 'PRADO_POSTBACK_TARGET', - + FIELD_POSTBACK_PARAMETER : 'PRADO_POSTBACK_PARAMETER', /** @@ -113,7 +113,7 @@ Object.extend(Prado.CallbackRequest, * Current requests in progress. */ requestInProgress : null, - + /** * Add ids of inputs element to post in the request. */ @@ -121,7 +121,7 @@ Object.extend(Prado.CallbackRequest, { this.PostDataLoaders = this.PostDataLoaders.concat(ids); }, - + /** * Dispatch callback response actions. */ @@ -130,7 +130,7 @@ Object.extend(Prado.CallbackRequest, if(actions && actions.length > 0) actions.each(this.__run.bind(this,transport)); }, - + /** * Prase and evaluate a Callback clien-side action */ @@ -143,13 +143,13 @@ Object.extend(Prado.CallbackRequest, method.toFunction().apply(this,command[method].concat(transport)); } catch(e) - { + { if(typeof(Logger) != "undefined") Prado.CallbackRequest.Exception.onException(null,e); } } }, - + /** * Respond to Prado Callback request exceptions. */ @@ -159,11 +159,11 @@ Object.extend(Prado.CallbackRequest, * Server returns 500 exception. Just log it. */ "on500" : function(request, transport, data) - { + { var e = request.getHeaderData(Prado.CallbackRequest.ERROR_HEADER); Logger.error("Callback Server Error "+e.code, this.formatException(e)); }, - + /** * Callback OnComplete event,logs reponse and data to console. */ @@ -186,7 +186,7 @@ Object.extend(Prado.CallbackRequest, Logger.warn(msg); } }, - + /** * Uncaught exceptions during callback response. */ @@ -196,10 +196,10 @@ Object.extend(Prado.CallbackRequest, $H(e).each(function(item) { msg += item.key+": "+item.value+"\n"; - }) + }) Logger.error('Uncaught Callback Client Exception:', msg); }, - + /** * Formats the exception message for display in console. */ @@ -219,7 +219,7 @@ Object.extend(Prado.CallbackRequest, return msg; } }, - + /** * @return string JSON encoded data. */ @@ -227,7 +227,7 @@ Object.extend(Prado.CallbackRequest, { return Prado.JSON.stringify(data); }, - + /** * @return mixed javascript data decoded from string using JSON decoding. */ @@ -238,7 +238,7 @@ Object.extend(Prado.CallbackRequest, else return null; }, - + /** * Dispatch a priority request, it will call abortRequestInProgress first. */ @@ -246,18 +246,18 @@ Object.extend(Prado.CallbackRequest, { //Logger.info("priority request "+callback.id) 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) }, - + /** * Dispatch a normal request, no timeouts or aborting of requests. */ @@ -266,7 +266,7 @@ Object.extend(Prado.CallbackRequest, // Logger.info("dispatching normal request"); new Ajax.Request(callback.url, callback.options); }, - + /** * Abort the current priority request in progress. */ @@ -284,7 +284,7 @@ Object.extend(Prado.CallbackRequest, } return false; }, - + /** * Updates the page state. It will update only if EnablePageStateUpdate and * HasPriority options are both true. @@ -317,44 +317,48 @@ Ajax.Responders.register({onComplete : function(request) //Add HTTP exception respones when logger is enabled. Event.OnLoad(function() -{ - if(typeof Logger != "undefined") +{ + if(typeof Logger != "undefined") Ajax.Responders.register(Prado.CallbackRequest.Exception); }); /** * Create and prepare a new callback request. + * Call the dispatch() method to start the callback request. + * + * request = new Prado.CallbackRequest(UniqueID, callback); + * request.dispatch(); + * */ -Prado.CallbackRequest.prototype = +Prado.CallbackRequest.prototype = { /** * Callback URL, same url as the current page. */ url : window.location.href, - + /** * Callback options, including onXXX events. */ options : { }, - + /** * Callback target ID. E.g. $control->getUniqueID(); */ id : null, - + /** * Current callback request. */ request : null, - + /** * Prepare and inititate a callback request. */ initialize : function(id, options) { this.id = id; - - this.options = + this.options = Object.extend( { RequestTimeOut : 30000, // 30 second timeout. EnablePageStateUpdate : true, @@ -362,14 +366,87 @@ Prado.CallbackRequest.prototype = CausesValidation : true, ValidationGroup : null, PostInputs : true - } - Object.extend(this.options, options || {}); - + }, options || {}); + }, + + /** + * Sets the request parameter + * @param {Object} parameter value + */ + setParameter : function(value) + { + this.options['params'] = value; + }, + + /** + * @return {Object} request paramater value. + */ + getParameter : function() + { + return this.options['params']; + }, + + /** + * Sets the callback request timeout. + * @param {integer} timeout in milliseconds + */ + setRequestTimeOut : function(timeout) + { + this.options['RequestTimeOut'] = timeout; + }, + + /** + * @return {integer} request timeout in milliseconds + */ + getRequestTimeOut : function() + { + return this.options['RequestTimeOut']; + }, + + /** + * Set true to enable validation on callback dispatch. + * @param {boolean} true to validate + */ + setCausesValidation : function(validate) + { + this.options['CausesValidation'] = validate; + }, + + /** + * @return {boolean} validate on request dispatch + */ + getCausesValidation : function() + { + return this.options['CausesValidation']; + }, + + /** + * Sets the validation group to validate during request dispatch. + * @param {string} validation group name + */ + setValidationGroup : function(group) + { + this.options['ValidationGroup'] = group; + }, + + /** + * @return {string} validation group name. + */ + getValidationGroup : function() + { + return this.options['ValidationGroup']; + }, + + /** + * Dispatch the callback request. + */ + dispatch : function() + { //override parameter and postBody options. - Object.extend(this.options, + Object.extend(this.options, { postBody : this._getPostData(), - parameters : '' + parameters : '' }); if(this.options.CausesValidation && typeof(Prado.Validation) != "undefined") @@ -378,7 +455,7 @@ Prado.CallbackRequest.prototype = if(Prado.Validation.validate(form,this.options.ValidationGroup,this) == false) return; } - + if(this.options.HasPriority) Prado.CallbackRequest.dispatchPriorityRequest(this); else @@ -386,7 +463,7 @@ Prado.CallbackRequest.prototype = }, /** - * Collects the form inputs, encode the parameters, and sets the callback + * 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. */ @@ -430,14 +507,15 @@ Prado.CallbackRequest.prototype = */ Prado.Callback = function(UniqueID, parameter, onSuccess, options) { - var callback = + var callback = { 'params' : parameter || '', 'onSuccess' : onSuccess || Prototype.emptyFunction }; Object.extend(callback, options || {}); - - new Prado.CallbackRequest(UniqueID, callback); + + request = new Prado.CallbackRequest(UniqueID, callback); + request.dispatch(); return false; } diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 0c95a6a5..cb944253 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -334,11 +334,16 @@ class TBaseActiveCallbackControl extends TBaseActiveControl } /** - * 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="..." - * @return string javascript statement to invoke a callback. + * Returns the javascript callback request instance. To invoke a callback + * request for this control call the dispatch() method on the + * request instance. Example code in javascript + * + * request = <%= $this->mycallback->ActiveControl->Javascript %>; + * request.setParameter('hello'); + * request.dispatch(); //make the callback request. + * + * @return string javascript client-side callback request object (javascript + * code) */ public function getJavascript() { -- cgit v1.2.3