summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-03-30 08:49:15 +0000
committerwei <>2007-03-30 08:49:15 +0000
commit9db5f1ef950e571d19cc70f1b22da1d77f22448b (patch)
treed46d16e555e5249a47e637e273494c8f0291422d
parent429e20f85c5d1f633fa64bacfc4b8b2426147487 (diff)
Fixed #504
-rw-r--r--.gitattributes2
-rw-r--r--framework/Web/Javascripts/js/compressed/ajax.js63
-rw-r--r--framework/Web/Javascripts/js/debug/ajax.js96
-rw-r--r--framework/Web/Javascripts/prado/activecontrols/ajax3.js88
-rw-r--r--framework/Web/Javascripts/prado/activecontrols/inlineeditor.js8
-rw-r--r--framework/Web/UI/ActiveControls/TBaseActiveControl.php2
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket504.page67
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket504.php27
8 files changed, 232 insertions, 121 deletions
diff --git a/.gitattributes b/.gitattributes
index 6a72c98d..64e443df 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2397,6 +2397,8 @@ tests/FunctionalTests/tickets/protected/pages/Ticket477.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket477.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket484.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket484.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket504.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket504.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket507.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket507.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket511.page -text
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js
index d67d6adb..c1ce7504 100644
--- a/framework/Web/Javascripts/js/compressed/ajax.js
+++ b/framework/Web/Javascripts/js/compressed/ajax.js
@@ -156,64 +156,63 @@ msg+=e.version+" "+e.time+"\n";return msg;}},encode:function(data)
{if(typeof(data)=="string"&&data.trim().length>0)
return Prado.JSON.parse(data);else
return null;},dispatchNormalRequest:function(callback)
-{new Prado.AjaxRequest(callback.url,callback.options);return true;},tryNextRequest:function()
+{callback.request(callback.url);return true;},tryNextRequest:function()
{var self=Prado.CallbackRequest;if(typeof(self.currentRequest)=='undefined'||self.currentRequest==null)
{if(self.requestQueue.length>0)
return self.dispatchQueue();}},updatePageState:function(request,transport)
-{var self=Prado.CallbackRequest;var pagestate=$(self.FIELD_CALLBACK_PAGESTATE);var enabled=request.options.EnablePageStateUpdate&&request.options.HasPriority;var aborted=self.currentRequest==null;if(enabled&&!aborted&&pagestate)
+{var self=Prado.CallbackRequest;var pagestate=$(self.FIELD_CALLBACK_PAGESTATE);var enabled=request.ActiveControl.EnablePageStateUpdate&&request.ActiveControl.HasPriority;var aborted=self.currentRequest==null;if(enabled&&!aborted&&pagestate)
{var data=request.getBodyContentPart(self.PAGESTATE_HEADER);if(typeof(data)=="string"&&data.length>0)
pagestate.value=data;else
{if(typeof(Logger)!="undefined")
Logger.warn("Missing page state:"+data);self.endCurrentRequest();return false;}}
self.endCurrentRequest();return true;},enqueue:function(callback)
{var self=Prado.CallbackRequest;self.requestQueue.push(callback);self.tryNextRequest();},dispatchQueue:function()
-{var self=Prado.CallbackRequest;var callback=self.requestQueue.shift();self.currentRequest=callback;callback.options.postBody=callback._getPostData(),callback.request=new Prado.AjaxRequest(callback.url,callback.options);callback.timeout=setTimeout(function()
-{self.abortRequest(callback.id);},callback.options.RequestTimeOut);},endCurrentRequest:function()
+{var self=Prado.CallbackRequest;var callback=self.requestQueue.shift();self.currentRequest=callback;callback.options.postBody=callback._getPostData(),callback.request(callback.url);callback.timeout=setTimeout(function()
+{self.abortRequest(callback.id);},callback.ActiveControl.RequestTimeOut);},endCurrentRequest:function()
{var self=Prado.CallbackRequest;clearTimeout(self.currentRequest.timeout);self.currentRequest=null;},abortRequest:function(id)
{var self=Prado.CallbackRequest;if(typeof(self.currentRequest)!='undefined'&&self.currentRequest!=null&&self.currentRequest.id==id)
-{var request=self.currentRequest.request;if(request.transport.readyState<4)
+{var request=self.currentRequest;if(request.transport.readyState<4)
request.transport.abort();self.endCurrentRequest();}
self.tryNextRequest();}})
Ajax.Responders.register({onComplete:function(request)
-{if(request.options.HasPriority)
+{if(request.ActiveControl.HasPriority)
Prado.CallbackRequest.tryNextRequest();}});Event.OnLoad(function()
{if(typeof Logger!="undefined")
-Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackRequest.prototype={initialize:function(id,options)
-{this.url=this.getCallbackUrl();this.request=null;this.Enabled=true;this.id=id;if(typeof(id)=="string")
-Prado.CallbackRequest.requests[id]=this;this.options=Object.extend({RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true},options||{});},getCallbackUrl:function()
+Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackRequest.prototype=Object.extend(Prado.AjaxRequest.prototype,{initialize:function(id,options)
+{this.url=this.getCallbackUrl();this.transport=Ajax.getTransport();this.Enabled=true;this.id=id;if(typeof(id)=="string")
+Prado.CallbackRequest.requests[id]=this;this.setOptions(Object.extend({RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true},options||{}));this.ActiveControl=this.options;},getCallbackUrl:function()
{return $('PRADO_PAGESTATE').form.action;},setCallbackParameter:function(value)
-{this.options['params']=value;},getCallbackParameter: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()
+{this.ActiveControl['CallbackParameter']=value;},getCallbackParameter:function()
+{return this.ActiveControl['CallbackParameter'];},setRequestTimeOut:function(timeout)
+{this.ActiveControl['RequestTimeOut']=timeout;},getRequestTimeOut:function()
+{return this.ActiveControl['RequestTimeOut'];},setCausesValidation:function(validate)
+{this.ActiveControl['CausesValidation']=validate;},getCausesValidation:function()
+{return this.ActiveControl['CausesValidation'];},setValidationGroup:function(group)
+{this.ActiveControl['ValidationGroup']=group;},getValidationGroup:function()
+{return this.ActiveControl['ValidationGroup'];},dispatch:function()
{if(typeof tinyMCE!="undefined")
-tinyMCE.triggerSave();Object.extend(this.options,{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)
+tinyMCE.triggerSave();if(this.ActiveControl.CausesValidation&&typeof(Prado.Validation)!="undefined")
+{var form=this.ActiveControl.Form||Prado.Validation.getForm();if(Prado.Validation.validate(form,this.ActiveControl.ValidationGroup,this)==false)
return false;}
-if(this.options.onPreDispatch)
-this.options.onPreDispatch(this,null);if(!this.Enabled)
-return;if(this.options.HasPriority)
+if(this.ActiveControl.onPreDispatch)
+this.ActiveControl.onPreDispatch(this,null);if(!this.Enabled)
+return;if(this.ActiveControl.HasPriority)
{return Prado.CallbackRequest.enqueue(this);}
else
return Prado.CallbackRequest.dispatchNormalRequest(this);},abort:function()
{return Prado.CallbackRequest.abortRequest(this.id);},_getPostData:function()
-{var data={};var callback=Prado.CallbackRequest;if(this.options.PostInputs!=false)
+{var data={};var callback=Prado.CallbackRequest;if(this.ActiveControl.PostInputs!=false)
{callback.PostDataLoaders.each(function(name)
{$A(document.getElementsByName(name)).each(function(element)
{if(element.type&&element.name==name)
{value=$F(element);if(typeof(value)!="undefined"&&value!=null)
data[name]=value;}})})}
-if(typeof(this.options.params)!="undefined")
-data[callback.FIELD_CALLBACK_PARAMETER]=callback.encode(this.options.params);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.options.EventTarget)
-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||{});request=new Prado.CallbackRequest(UniqueID,callback);request.dispatch();return false;}
+if(typeof(this.ActiveControl.CallbackParameter)!="undefined")
+data[callback.FIELD_CALLBACK_PARAMETER]=callback.encode(this.ActiveControl.CallbackParameter);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();}});Prado.Callback=function(UniqueID,parameter,onSuccess,options)
+{var callback={'CallbackParameter':parameter||'','onSuccess':onSuccess||Prototype.emptyFunction};Object.extend(callback,options||{});request=new Prado.CallbackRequest(UniqueID,callback);request.dispatch();return false;}
Prado.WebUI.CallbackControl=Class.extend(Prado.WebUI.PostBackControl,{onPostBack:function(event,options)
{var request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveLinkButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveImageButton=Class.extend(Prado.WebUI.TImageButton,{onPostBack:function(event,options)
{this.addXYInput(event,options);var request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveCheckBox=Class.extend(Prado.WebUI.CallbackControl,{onPostBack:function(event,options)
@@ -276,7 +275,7 @@ Event.stop(evt);return false;},exitEditMode:function(evt)
{Element.show(this.element);Element.hide(this.editField);},createEditorInput:function()
{if(this.editField==null)
this.createTextBox();this.editField.value=this.getText();},loadExternalText:function()
-{this.editField.disabled=true;this.onLoadingText();options=new Array('__InlineEditor_loadExternalText__',this.getText());request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setCausesValidation(false);request.setCallbackParameter(options);request.options.onSuccess=this.onloadExternalTextSuccess.bind(this);request.options.onFailure=this.onloadExternalTextFailure.bind(this);request.dispatch();},createTextBox:function()
+{this.editField.disabled=true;this.onLoadingText();options=new Array('__InlineEditor_loadExternalText__',this.getText());request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setCausesValidation(false);request.setCallbackParameter(options);request.ActiveControl.onSuccess=this.onloadExternalTextSuccess.bind(this);request.ActiveControl.onFailure=this.onloadExternalTextFailure.bind(this);request.dispatch();},createTextBox:function()
{cssClass=this.element.className||'';inputName=this.options.EventTarget;options={'className':cssClass,name:inputName,id:this.options.TextBoxID};if(this.options.TextMode=='SingleLine')
{if(this.options.MaxLength>0)
options['maxlength']=this.options.MaxLength;this.editField=INPUT(options);}
@@ -299,7 +298,7 @@ this.options.onEnterEditMode(this,null);},onTextBoxBlur:function(e)
this.onTextChanged(text);else
{this.element.innerHTML=this.editField.value;this.isEditing=false;if(this.options.AutoHide)
this.showLabel();}},onTextChanged:function(text)
-{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setCallbackParameter(text);request.options.onSuccess=this.onTextChangedSuccess.bind(this);request.options.onFailure=this.onTextChangedFailure.bind(this);if(request.dispatch())
+{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setCallbackParameter(text);request.ActiveControl.onSuccess=this.onTextChangedSuccess.bind(this);request.ActiveControl.onFailure=this.onTextChangedFailure.bind(this);if(request.dispatch())
{this.isSaving=true;this.editField.disabled=true;}},onLoadingText:function()
{},onloadExternalTextSuccess:function(request,parameter)
{this.isEditing=true;this.editField.disabled=false;this.editField.value=this.getText();Prado.Element.focus(this.editField);if(typeof(this.options.onSuccess)=="function")
diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js
index 6ae0ab40..4b20a8de 100644
--- a/framework/Web/Javascripts/js/debug/ajax.js
+++ b/framework/Web/Javascripts/js/debug/ajax.js
@@ -1219,6 +1219,14 @@ Prado.AjaxRequest.prototype = Ajax.Request.prototype;
*/
Object.extend(Prado.AjaxRequest.prototype,
{
+ /*initialize: function(request)
+ {
+ this.CallbackRequest = request;
+ this.transport = Ajax.getTransport();
+ this.setOptions(request.options);
+ this.request(request.url);
+ },*/
+
/**
* Customize the response, dispatch onXXX response code events, and
* tries to execute response actions (javascript statements).
@@ -1523,7 +1531,8 @@ Object.extend(Prado.CallbackRequest,
dispatchNormalRequest : function(callback)
{
//Logger.info("dispatching normal request");
- new Prado.AjaxRequest(callback.url, callback.options);
+ //new Prado.AjaxRequest(callback);
+ callback.request(callback.url);
return true;
},
@@ -1553,7 +1562,7 @@ Object.extend(Prado.CallbackRequest,
{
var self = Prado.CallbackRequest;
var pagestate = $(self.FIELD_CALLBACK_PAGESTATE);
- var enabled = request.options.EnablePageStateUpdate && request.options.HasPriority;
+ var enabled = request.ActiveControl.EnablePageStateUpdate && request.ActiveControl.HasPriority;
var aborted = self.currentRequest == null;
if(enabled && !aborted && pagestate)
{
@@ -1594,12 +1603,13 @@ Object.extend(Prado.CallbackRequest,
//get data
callback.options.postBody = callback._getPostData(),
- callback.request = new Prado.AjaxRequest(callback.url, callback.options);
+ //callback.request = new Prado.AjaxRequest(callback);
+ callback.request(callback.url);
callback.timeout = setTimeout(function()
{
//Logger.warn("priority timeout");
self.abortRequest(callback.id);
- },callback.options.RequestTimeOut);
+ },callback.ActiveControl.RequestTimeOut);
//Logger.debug("dispatched "+self.currentRequest.id + " ...")
},
@@ -1617,7 +1627,7 @@ Object.extend(Prado.CallbackRequest,
if(typeof(self.currentRequest) != 'undefined'
&& self.currentRequest != null && self.currentRequest.id == id)
{
- var request = self.currentRequest.request;
+ var request = self.currentRequest;
if(request.transport.readyState < 4)
request.transport.abort();
//Logger.warn('## aborted: setting current request to null');
@@ -1632,7 +1642,7 @@ Object.extend(Prado.CallbackRequest,
*/
Ajax.Responders.register({onComplete : function(request)
{
- if(request.options.HasPriority)
+ if(request.ActiveControl.HasPriority)
Prado.CallbackRequest.tryNextRequest();
}});
@@ -1651,7 +1661,7 @@ Event.OnLoad(function()
* request.dispatch();
* </code>
*/
-Prado.CallbackRequest.prototype =
+Prado.CallbackRequest.prototype = Object.extend(Prado.AjaxRequest.prototype,
{
/**
@@ -1664,10 +1674,13 @@ Prado.CallbackRequest.prototype =
*/
this.url = this.getCallbackUrl();
+ this.transport = Ajax.getTransport();
+// this.setOptions(request.options);
+// this.request(request.url);
/**
* Current callback request.
*/
- this.request = null;
+ //this.request = null;
this.Enabled = true;
@@ -1675,7 +1688,7 @@ Prado.CallbackRequest.prototype =
if(typeof(id)=="string")
Prado.CallbackRequest.requests[id] = this;
- this.options = Object.extend(
+ this.setOptions(Object.extend(
{
RequestTimeOut : 30000, // 30 second timeout.
EnablePageStateUpdate : true,
@@ -1683,7 +1696,9 @@ Prado.CallbackRequest.prototype =
CausesValidation : true,
ValidationGroup : null,
PostInputs : true
- }, options || {});
+ }, options || {}));
+
+ this.ActiveControl = this.options;
},
/**
@@ -1701,7 +1716,7 @@ Prado.CallbackRequest.prototype =
*/
setCallbackParameter : function(value)
{
- this.options['params'] = value;
+ this.ActiveControl['CallbackParameter'] = value;
},
/**
@@ -1709,7 +1724,7 @@ Prado.CallbackRequest.prototype =
*/
getCallbackParameter : function()
{
- return this.options['params'];
+ return this.ActiveControl['CallbackParameter'];
},
/**
@@ -1718,7 +1733,7 @@ Prado.CallbackRequest.prototype =
*/
setRequestTimeOut : function(timeout)
{
- this.options['RequestTimeOut'] = timeout;
+ this.ActiveControl['RequestTimeOut'] = timeout;
},
/**
@@ -1726,7 +1741,7 @@ Prado.CallbackRequest.prototype =
*/
getRequestTimeOut : function()
{
- return this.options['RequestTimeOut'];
+ return this.ActiveControl['RequestTimeOut'];
},
/**
@@ -1735,7 +1750,7 @@ Prado.CallbackRequest.prototype =
*/
setCausesValidation : function(validate)
{
- this.options['CausesValidation'] = validate;
+ this.ActiveControl['CausesValidation'] = validate;
},
/**
@@ -1743,7 +1758,7 @@ Prado.CallbackRequest.prototype =
*/
getCausesValidation : function()
{
- return this.options['CausesValidation'];
+ return this.ActiveControl['CausesValidation'];
},
/**
@@ -1752,7 +1767,7 @@ Prado.CallbackRequest.prototype =
*/
setValidationGroup : function(group)
{
- this.options['ValidationGroup'] = group;
+ this.ActiveControl['ValidationGroup'] = group;
},
/**
@@ -1760,7 +1775,7 @@ Prado.CallbackRequest.prototype =
*/
getValidationGroup : function()
{
- return this.options['ValidationGroup'];
+ return this.ActiveControl['ValidationGroup'];
},
/**
@@ -1773,27 +1788,20 @@ Prado.CallbackRequest.prototype =
if(typeof tinyMCE != "undefined")
tinyMCE.triggerSave();
- //override parameter and postBody options.
- Object.extend(this.options,
+ if(this.ActiveControl.CausesValidation && typeof(Prado.Validation) != "undefined")
{
-// 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)
+ var form = this.ActiveControl.Form || Prado.Validation.getForm();
+ if(Prado.Validation.validate(form,this.ActiveControl.ValidationGroup,this) == false)
return false;
}
- if(this.options.onPreDispatch)
- this.options.onPreDispatch(this,null);
+ if(this.ActiveControl.onPreDispatch)
+ this.ActiveControl.onPreDispatch(this,null);
if(!this.Enabled)
return;
- if(this.options.HasPriority)
+ if(this.ActiveControl.HasPriority)
{
return Prado.CallbackRequest.enqueue(this);
//return Prado.CallbackRequest.dispatchPriorityRequest(this);
@@ -1816,7 +1824,7 @@ Prado.CallbackRequest.prototype =
{
var data = {};
var callback = Prado.CallbackRequest;
- if(this.options.PostInputs != false)
+ if(this.ActiveControl.PostInputs != false)
{
callback.PostDataLoaders.each(function(name)
{
@@ -1832,19 +1840,19 @@ Prado.CallbackRequest.prototype =
})
})
}
- if(typeof(this.options.params) != "undefined")
- data[callback.FIELD_CALLBACK_PARAMETER] = callback.encode(this.options.params);
+ if(typeof(this.ActiveControl.CallbackParameter) != "undefined")
+ data[callback.FIELD_CALLBACK_PARAMETER] = callback.encode(this.ActiveControl.CallbackParameter);
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.options.EventTarget)
- data[callback.FIELD_POSTBACK_TARGET] = this.options.EventTarget;
- if(this.options.EventParameter)
- data[callback.FIELD_POSTBACK_PARAMETER] = this.options.EventParameter;
+ 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();
}
-}
+});
/**
* Create a new callback request using default settings.
@@ -1858,7 +1866,7 @@ Prado.Callback = function(UniqueID, parameter, onSuccess, options)
{
var callback =
{
- 'params' : parameter || '',
+ 'CallbackParameter' : parameter || '',
'onSuccess' : onSuccess || Prototype.emptyFunction
};
@@ -2295,8 +2303,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
request.setCausesValidation(false);
request.setCallbackParameter(options);
- request.options.onSuccess = this.onloadExternalTextSuccess.bind(this);
- request.options.onFailure = this.onloadExternalTextFailure.bind(this);
+ request.ActiveControl.onSuccess = this.onloadExternalTextSuccess.bind(this);
+ request.ActiveControl.onFailure = this.onloadExternalTextFailure.bind(this);
request.dispatch();
},
@@ -2387,8 +2395,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
{
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
request.setCallbackParameter(text);
- request.options.onSuccess = this.onTextChangedSuccess.bind(this);
- request.options.onFailure = this.onTextChangedFailure.bind(this);
+ request.ActiveControl.onSuccess = this.onTextChangedSuccess.bind(this);
+ request.ActiveControl.onFailure = this.onTextChangedFailure.bind(this);
if(request.dispatch())
{
this.isSaving = true;
diff --git a/framework/Web/Javascripts/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/prado/activecontrols/ajax3.js
index a8906a78..dbf768a6 100644
--- a/framework/Web/Javascripts/prado/activecontrols/ajax3.js
+++ b/framework/Web/Javascripts/prado/activecontrols/ajax3.js
@@ -8,6 +8,14 @@ Prado.AjaxRequest.prototype = Ajax.Request.prototype;
*/
Object.extend(Prado.AjaxRequest.prototype,
{
+ /*initialize: function(request)
+ {
+ this.CallbackRequest = request;
+ this.transport = Ajax.getTransport();
+ this.setOptions(request.options);
+ this.request(request.url);
+ },*/
+
/**
* Customize the response, dispatch onXXX response code events, and
* tries to execute response actions (javascript statements).
@@ -312,7 +320,8 @@ Object.extend(Prado.CallbackRequest,
dispatchNormalRequest : function(callback)
{
//Logger.info("dispatching normal request");
- new Prado.AjaxRequest(callback.url, callback.options);
+ //new Prado.AjaxRequest(callback);
+ callback.request(callback.url);
return true;
},
@@ -342,7 +351,7 @@ Object.extend(Prado.CallbackRequest,
{
var self = Prado.CallbackRequest;
var pagestate = $(self.FIELD_CALLBACK_PAGESTATE);
- var enabled = request.options.EnablePageStateUpdate && request.options.HasPriority;
+ var enabled = request.ActiveControl.EnablePageStateUpdate && request.ActiveControl.HasPriority;
var aborted = self.currentRequest == null;
if(enabled && !aborted && pagestate)
{
@@ -383,12 +392,13 @@ Object.extend(Prado.CallbackRequest,
//get data
callback.options.postBody = callback._getPostData(),
- callback.request = new Prado.AjaxRequest(callback.url, callback.options);
+ //callback.request = new Prado.AjaxRequest(callback);
+ callback.request(callback.url);
callback.timeout = setTimeout(function()
{
//Logger.warn("priority timeout");
self.abortRequest(callback.id);
- },callback.options.RequestTimeOut);
+ },callback.ActiveControl.RequestTimeOut);
//Logger.debug("dispatched "+self.currentRequest.id + " ...")
},
@@ -406,7 +416,7 @@ Object.extend(Prado.CallbackRequest,
if(typeof(self.currentRequest) != 'undefined'
&& self.currentRequest != null && self.currentRequest.id == id)
{
- var request = self.currentRequest.request;
+ var request = self.currentRequest;
if(request.transport.readyState < 4)
request.transport.abort();
//Logger.warn('## aborted: setting current request to null');
@@ -421,7 +431,7 @@ Object.extend(Prado.CallbackRequest,
*/
Ajax.Responders.register({onComplete : function(request)
{
- if(request.options.HasPriority)
+ if(request.ActiveControl.HasPriority)
Prado.CallbackRequest.tryNextRequest();
}});
@@ -440,7 +450,7 @@ Event.OnLoad(function()
* request.dispatch();
* </code>
*/
-Prado.CallbackRequest.prototype =
+Prado.CallbackRequest.prototype = Object.extend(Prado.AjaxRequest.prototype,
{
/**
@@ -453,10 +463,13 @@ Prado.CallbackRequest.prototype =
*/
this.url = this.getCallbackUrl();
+ this.transport = Ajax.getTransport();
+// this.setOptions(request.options);
+// this.request(request.url);
/**
* Current callback request.
*/
- this.request = null;
+ //this.request = null;
this.Enabled = true;
@@ -464,7 +477,7 @@ Prado.CallbackRequest.prototype =
if(typeof(id)=="string")
Prado.CallbackRequest.requests[id] = this;
- this.options = Object.extend(
+ this.setOptions(Object.extend(
{
RequestTimeOut : 30000, // 30 second timeout.
EnablePageStateUpdate : true,
@@ -472,7 +485,9 @@ Prado.CallbackRequest.prototype =
CausesValidation : true,
ValidationGroup : null,
PostInputs : true
- }, options || {});
+ }, options || {}));
+
+ this.ActiveControl = this.options;
},
/**
@@ -490,7 +505,7 @@ Prado.CallbackRequest.prototype =
*/
setCallbackParameter : function(value)
{
- this.options['params'] = value;
+ this.ActiveControl['CallbackParameter'] = value;
},
/**
@@ -498,7 +513,7 @@ Prado.CallbackRequest.prototype =
*/
getCallbackParameter : function()
{
- return this.options['params'];
+ return this.ActiveControl['CallbackParameter'];
},
/**
@@ -507,7 +522,7 @@ Prado.CallbackRequest.prototype =
*/
setRequestTimeOut : function(timeout)
{
- this.options['RequestTimeOut'] = timeout;
+ this.ActiveControl['RequestTimeOut'] = timeout;
},
/**
@@ -515,7 +530,7 @@ Prado.CallbackRequest.prototype =
*/
getRequestTimeOut : function()
{
- return this.options['RequestTimeOut'];
+ return this.ActiveControl['RequestTimeOut'];
},
/**
@@ -524,7 +539,7 @@ Prado.CallbackRequest.prototype =
*/
setCausesValidation : function(validate)
{
- this.options['CausesValidation'] = validate;
+ this.ActiveControl['CausesValidation'] = validate;
},
/**
@@ -532,7 +547,7 @@ Prado.CallbackRequest.prototype =
*/
getCausesValidation : function()
{
- return this.options['CausesValidation'];
+ return this.ActiveControl['CausesValidation'];
},
/**
@@ -541,7 +556,7 @@ Prado.CallbackRequest.prototype =
*/
setValidationGroup : function(group)
{
- this.options['ValidationGroup'] = group;
+ this.ActiveControl['ValidationGroup'] = group;
},
/**
@@ -549,7 +564,7 @@ Prado.CallbackRequest.prototype =
*/
getValidationGroup : function()
{
- return this.options['ValidationGroup'];
+ return this.ActiveControl['ValidationGroup'];
},
/**
@@ -562,27 +577,20 @@ Prado.CallbackRequest.prototype =
if(typeof tinyMCE != "undefined")
tinyMCE.triggerSave();
- //override parameter and postBody options.
- Object.extend(this.options,
- {
-// postBody : this._getPostData(),
- parameters : ''
- });
-
- if(this.options.CausesValidation && typeof(Prado.Validation) != "undefined")
+ if(this.ActiveControl.CausesValidation && typeof(Prado.Validation) != "undefined")
{
- var form = this.options.Form || Prado.Validation.getForm();
- if(Prado.Validation.validate(form,this.options.ValidationGroup,this) == false)
+ var form = this.ActiveControl.Form || Prado.Validation.getForm();
+ if(Prado.Validation.validate(form,this.ActiveControl.ValidationGroup,this) == false)
return false;
}
- if(this.options.onPreDispatch)
- this.options.onPreDispatch(this,null);
+ if(this.ActiveControl.onPreDispatch)
+ this.ActiveControl.onPreDispatch(this,null);
if(!this.Enabled)
return;
- if(this.options.HasPriority)
+ if(this.ActiveControl.HasPriority)
{
return Prado.CallbackRequest.enqueue(this);
//return Prado.CallbackRequest.dispatchPriorityRequest(this);
@@ -605,7 +613,7 @@ Prado.CallbackRequest.prototype =
{
var data = {};
var callback = Prado.CallbackRequest;
- if(this.options.PostInputs != false)
+ if(this.ActiveControl.PostInputs != false)
{
callback.PostDataLoaders.each(function(name)
{
@@ -621,19 +629,19 @@ Prado.CallbackRequest.prototype =
})
})
}
- if(typeof(this.options.params) != "undefined")
- data[callback.FIELD_CALLBACK_PARAMETER] = callback.encode(this.options.params);
+ if(typeof(this.ActiveControl.CallbackParameter) != "undefined")
+ data[callback.FIELD_CALLBACK_PARAMETER] = callback.encode(this.ActiveControl.CallbackParameter);
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.options.EventTarget)
- data[callback.FIELD_POSTBACK_TARGET] = this.options.EventTarget;
- if(this.options.EventParameter)
- data[callback.FIELD_POSTBACK_PARAMETER] = this.options.EventParameter;
+ 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();
}
-}
+});
/**
* Create a new callback request using default settings.
@@ -647,7 +655,7 @@ Prado.Callback = function(UniqueID, parameter, onSuccess, options)
{
var callback =
{
- 'params' : parameter || '',
+ 'CallbackParameter' : parameter || '',
'onSuccess' : onSuccess || Prototype.emptyFunction
};
diff --git a/framework/Web/Javascripts/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/prado/activecontrols/inlineeditor.js
index c73985f7..fdf0e9f5 100644
--- a/framework/Web/Javascripts/prado/activecontrols/inlineeditor.js
+++ b/framework/Web/Javascripts/prado/activecontrols/inlineeditor.js
@@ -89,8 +89,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
request.setCausesValidation(false);
request.setCallbackParameter(options);
- request.options.onSuccess = this.onloadExternalTextSuccess.bind(this);
- request.options.onFailure = this.onloadExternalTextFailure.bind(this);
+ request.ActiveControl.onSuccess = this.onloadExternalTextSuccess.bind(this);
+ request.ActiveControl.onFailure = this.onloadExternalTextFailure.bind(this);
request.dispatch();
},
@@ -181,8 +181,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
{
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
request.setCallbackParameter(text);
- request.options.onSuccess = this.onTextChangedSuccess.bind(this);
- request.options.onFailure = this.onTextChangedFailure.bind(this);
+ request.ActiveControl.onSuccess = this.onTextChangedSuccess.bind(this);
+ request.ActiveControl.onFailure = this.onTextChangedFailure.bind(this);
if(request.dispatch())
{
this.isSaving = true;
diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
index ebd9d168..90cebb75 100644
--- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php
+++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
@@ -328,7 +328,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
$validate = $this->getCausesValidation();
$options['CausesValidation']= $validate ? '' : false;
$options['ValidationGroup']=$this->getValidationGroup();
- $options['params'] = $this->getCallbackParameter();
+ $options['CallbackParameter'] = $this->getCallbackParameter();
return $options;
}
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket504.page b/tests/FunctionalTests/tickets/protected/pages/Ticket504.page
new file mode 100644
index 00000000..0242dd97
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket504.page
@@ -0,0 +1,67 @@
+<com:TContent ID="Content">
+
+<com:TCallback ID="loadData" OnCallback="loadData_Callback"/>
+
+<div style="height:1em">
+<div id="loading" style="display:none"> loading...</div>
+</div>
+<div id="status"></div>
+
+<com:TCallbackOptions ID="LoadDataOptions">
+ <prop:ClientSide.OnSuccess>
+ $('status').innerHTML = sender.ActiveControl.CallbackParameter + " updated";
+ </prop:ClientSide.OnSuccess>
+
+ <prop:ClientSide.OnLoading>
+ $('loading').show();
+ </prop:ClientSide.OnLoading>
+
+ <prop:ClientSide.OnComplete>
+ $('loading').hide();
+ </prop:ClientSide.OnComplete>
+</com:TCallbackOptions>
+
+
+
+<com:TActiveLinkButton
+ Text="Tab A"
+ OnCallback="changePanel"
+ ActiveControl.CallbackOptions="LoadDataOptions"
+ ActiveControl.CallbackParameter="panelA"
+ />
+<com:TActiveLinkButton
+ Text="Tab B"
+ OnCallback="changePanel"
+ ActiveControl.CallbackOptions="LoadDataOptions"
+ ActiveControl.CallbackParameter="panelB"
+ />
+<com:TActiveLinkButton
+ Text="Tab C"
+ OnCallback="changePanel"
+ ActiveControl.CallbackOptions="LoadDataOptions"
+ ActiveControl.CallbackParameter="panelC"
+ />
+<com:TActiveLinkButton
+ Text="Tab D"
+ OnCallback="changePanel"
+ ActiveControl.CallbackOptions="LoadDataOptions"
+ ActiveControl.CallbackParameter="panelD"
+ />
+
+<com:TActivePanel ID="panelA">
+ <h1>Panel A</h1>
+</com:TActivePanel>
+
+<com:TActivePanel ID="panelB">
+ <h1>Panel B</h1>
+</com:TActivePanel>
+
+<com:TActivePanel ID="panelC">
+ <h1>Panel C</h1>
+</com:TActivePanel>
+
+<com:TActivePanel ID="panelD">
+ <h1>Panel D</h1>
+</com:TActivePanel>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket504.php b/tests/FunctionalTests/tickets/protected/pages/Ticket504.php
new file mode 100644
index 00000000..f61bfec3
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket504.php
@@ -0,0 +1,27 @@
+<?php
+
+Prado::using('System.Web.UI.ActiveControls.*');
+
+class Ticket504 extends TPage
+{
+ private $panels = array('panelA', 'panelB', 'panelC','panelD',);
+ private function showPanel($id, $param) {
+ foreach($this->panels as $panel) {
+ if($id == $panel) {
+ $this->$panel->setAttribute('style', 'display: block;');
+ $this->$panel->render($param->NewWriter);
+ $this->$panel->setVisible(true);
+ } else {
+ $this->$panel->setVisible(false);
+ }
+ }
+ }
+ public function changePanel($sender,$param){
+ $this->showPanel($param->CallbackParameter, $param);
+ }
+ public function loadData_Callback($sender, $param){
+ die("parameter is ".$param->CallbackParameter);
+ }
+}
+
+?> \ No newline at end of file