diff options
author | wei <> | 2006-12-09 09:17:22 +0000 |
---|---|---|
committer | wei <> | 2006-12-09 09:17:22 +0000 |
commit | 3c03a42d1edb0ec26110ace00f42e156cabff67b (patch) | |
tree | 66baa1cd4afca87668be07e62406e7d538dd1fbb /framework/Web | |
parent | 33b2284955a8f0015922d4c69c5082141b584f27 (diff) |
Fixed #433, #384, #439, #477, #435, #422, #401, #359. Add more class docs for sqlmap.
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/js/compressed/ajax.js | 63 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/compressed/prado.js | 16 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/debug/ajax.js | 169 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/debug/prado.js | 23 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/activecontrols3.js | 56 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/ajax3.js | 113 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/controls.js | 23 | ||||
-rw-r--r-- | framework/Web/THttpResponse.php | 29 | ||||
-rw-r--r-- | framework/Web/THttpResponseAdapter.php | 19 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveLinkButton.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActivePageAdapter.php | 21 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TAutoComplete.php | 32 | ||||
-rwxr-xr-x | framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php | 21 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php | 47 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TValueTriggeredCallback.php | 26 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TTextBox.php | 3 |
16 files changed, 309 insertions, 354 deletions
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index 4b260ab3..593b4c15 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -22,7 +22,8 @@ if(this.responseIsSuccess()){if(this.onComplete) setTimeout(this.onComplete.bind(this),10);}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(container,url,options){this.setOptions(options);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=container;this.url=url;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(request){if(this.options.decay){this.decay=(request.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=request.responseText;} this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});Object.extend(Ajax.Request.prototype,{respondToReadyState:function(readyState) {var event=Ajax.Request.Events[readyState];var transport=this.transport,json=this.getHeaderData(Prado.CallbackRequest.DATA_HEADER);if(event=='Complete') -{if((this.header('Content-type')||'').match(/^text\/javascript/i)) +{if(this.header('X-PRADO-REDIRECT')) +document.location.href=this.header('X-PRADO-REDIRECT');if((this.header('Content-type')||'').match(/^text\/javascript/i)) {try {json=eval('('+transport.responseText+')');}catch(e) {if(typeof(json)=="string") @@ -36,7 +37,7 @@ this.transport.onreadystatechange=Prototype.emptyFunction;},getHeaderData:functi {var json=this.header(name);return eval('('+json+')');} catch(e) {if(typeof(json)=="string") -return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',currentRequest:null,requestQueue:[],addPostLoaders:function(ids) +return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',requestQueue:[],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;},dispatchActions:function(transport,actions) @@ -65,35 +66,28 @@ msg+=e.version+" "+e.time+"\n";return msg;}},encode:function(data) {return Prado.JSON.stringify(data);},decode:function(data) {if(typeof(data)=="string"&&data.trim().length>0) return Prado.JSON.parse(data);else -return null;},dispatchPriorityRequest:function(callback) -{var self=Prado.CallbackRequest;callback.request=new Ajax.Request(callback.url,callback.options);callback.timeout=setTimeout(function() -{self.abortCurrentRequest();},callback.options.RequestTimeOut);self.currentRequest=callback;return true;},dispatchNormalRequest:function(callback) -{new Ajax.Request(callback.url,callback.options);return true;},abortCurrentRequest:function() -{var self=Prado.CallbackRequest;var inProgress=self.currentRequest;if(inProgress) -{clearTimeout(inProgress.timeout);self.currentRequest=null;if(inProgress.request.transport.readyState<4) -inProgress.request.transport.abort();return self.dispatchQueue();} -else -return self.dispatchQueue();},updatePageState:function(request,transport) +return null;},dispatchNormalRequest:function(callback) +{new Ajax.Request(callback.url,callback.options);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 data=request.header(self.PAGESTATE_HEADER);if(typeof(data)=="string"&&data.length>0) pagestate.value=data;else {if(typeof(Logger)!="undefined") -Logger.warn("Missing page state:"+data);return false;}} -return true;},enqueue:function(callback) -{var self=Prado.CallbackRequest;if(self.currentRequest==null) -self.dispatchPriorityRequest(callback);else -self.requestQueue.push(callback);},dispatchQueue:function() -{var self=Prado.CallbackRequest;if(self.requestQueue.length>0) -{var callback=self.requestQueue.shift();return self.dispatchPriorityRequest(callback);} -return false;},abortRequest:function(id) -{var self=Prado.CallbackRequest;if(self.currentRequest!=null&&self.currentRequest.id==id) -self.abortCurrentRequest();else -{var queque=[];self.requestQueue.each(function(callback) -{if(callback.id!=id) -queque.push(callback);});self.requestQueue=queque;}}}) +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 Ajax.Request(callback.url,callback.options);callback.timeout=setTimeout(function() +{self.abortRequest(callback.id);},callback.options.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) +request.transport.abort();self.endCurrentRequest();} +self.tryNextRequest();}}) Ajax.Responders.register({onComplete:function(request) {if(request.options.HasPriority) -Prado.CallbackRequest.abortCurrentRequest();}});Event.OnLoad(function() +Prado.CallbackRequest.tryNextRequest();}});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,Enabled:true,initialize:function(id,options) {this.id=id;this.options=Object.extend({RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true},options||{});},setCallbackParameter:function(value) @@ -106,7 +100,7 @@ Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackReque {this.options['ValidationGroup']=group;},getValidationGroup:function() {return this.options['ValidationGroup'];},dispatch:function() {if(typeof tinyMCE!="undefined") -tinyMCE.triggerSave();Object.extend(this.options,{postBody:this._getPostData(),parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="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) return false;} if(this.options.onPreDispatch) @@ -241,16 +235,13 @@ this.onInit(options);},doCallback:function(event,options) {var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();Event.fireEvent(this.element,"change");},getUpdatedChoices:function() {var options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},onComplete:function(request,boundary) {var result=Prado.Element.extractContent(request.transport.responseText,boundary);if(typeof(result)=="string"&&result.length>0) -this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({count:0,timeout:0,constructor:function(options) -{this.options=Object.extend({Interval:1,DecayRate:0},options||{}) -this.onComplete=this.options.onComplete;Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function() -{this.options.onComplete=this.onRequestComplete.bind(this);this.timer=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;var request=new Prado.CallbackRequest(this.options.EventTarget,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;} -this.timeout=(t+this.options.Interval)*1000;this.count++;return parseInt(this.timeout);}},{timers:{},register:function(timer) +this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({constructor:function(options) +{this.options=Object.extend({Interval:1},options||{});Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function() +{setTimeout(this.onTimerEvent.bind(this),100);if(typeof(this.timer)=='undefined'||this.timer==null) +this.timer=setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);},stopTimer:function() +{if(typeof(this.timer)!='undefined') +{clearInterval(this.timer);this.timer=null;}},onTimerEvent:function() +{var request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();}},{timers:{},register:function(timer) {Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID]=timer;},start:function(id) {Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();},stop:function(id) {Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options) diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js index 9f8cdb19..9e0b9ba8 100644 --- a/framework/Web/Javascripts/js/compressed/prado.js +++ b/framework/Web/Javascripts/js/compressed/prado.js @@ -371,11 +371,17 @@ else {y_input=INPUT({type:'hidden',name:id+'_y','id':id+'_y',value:y});this.element.parentNode.appendChild(y_input);}}});Prado.WebUI.TRadioButton=Class.extend(Prado.WebUI.PostBackControl);Prado.WebUI.TRadioButton.prototype.onRadioButtonInitialize=Prado.WebUI.TRadioButton.prototype.initialize;Object.extend(Prado.WebUI.TRadioButton.prototype,{initialize:function(options) {this.element=$(options['ID']);if(!this.element.checked) this.onRadioButtonInitialize(options);}});Prado.WebUI.TTextBox=Class.extend(Prado.WebUI.PostBackControl,{onInit:function(options) -{if(options['TextMode']!='MultiLine') -Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.observe(this.element,"change",Prado.PostBack.bindEvent(this,options));},handleReturnKey:function(e) +{this.options=options;if(options['TextMode']!='MultiLine') +Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));if(this.options['AutoPostBack']==true) +Event.observe(this.element,"change",Prado.PostBack.bindEvent(this,options));},handleReturnKey:function(e) {if(Event.keyCode(e)==Event.KEY_RETURN) {var target=Event.element(e);if(target) -{Event.fireEvent(target,"change");Event.stop(e);}}}});Prado.WebUI.TListControl=Class.extend(Prado.WebUI.PostBackControl,{onInit:function(options) +{if(this.options['AutoPostBack']==true) +{Event.fireEvent(target,"change");Event.stop(e);} +else +{if(this.options['CausesValidation']&&typeof(Prado.Validation)!="undefined") +{if(!Prado.Validation.validate(this.options['FormID'],this.options['ValidationGroup'],$(this.options['ID']))) +return Event.stop(e);}}}}}});Prado.WebUI.TListControl=Class.extend(Prado.WebUI.PostBackControl,{onInit:function(options) {Event.observe(this.element,"change",Prado.PostBack.bindEvent(this,options));}});Prado.WebUI.TListBox=Class.extend(Prado.WebUI.TListControl);Prado.WebUI.TDropDownList=Class.extend(Prado.WebUI.TListControl);Prado.WebUI.DefaultButton=Class.create();Prado.WebUI.DefaultButton.prototype={initialize:function(options) {this.options=options;this._event=this.triggerEvent.bindEvent(this);Event.observe(options['Panel'],'keydown',this._event);},triggerEvent:function(ev,target) {var enterPressed=Event.keyCode(ev)==Event.KEY_RETURN;var isTextArea=Event.element(ev).tagName.toLowerCase()=="textarea";if(enterPressed&&!isTextArea) @@ -392,6 +398,6 @@ window.clipboardData.setData("Text",text);},hover:function(obj) {obj.parentNode.className="copycode copycode_hover";},out:function(obj) {obj.parentNode.className="copycode";}});Prado.WebUI.TCheckBoxList=Base.extend({constructor:function(options) {for(var i=0;i<options.ItemCount;i++) -{var checkBoxOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListID+"$c"+i},options);new Prado.WebUI.TCheckBox(checkBoxOptions);}}});Prado.WebUI.TRadioButtonList=Base.extend({constructor:function(options) +{var checkBoxOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TCheckBox(checkBoxOptions);}}});Prado.WebUI.TRadioButtonList=Base.extend({constructor:function(options) {for(var i=0;i<options.ItemCount;i++) -{var radioButtonOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListID+"$c"+i},options);new Prado.WebUI.TRadioButton(radioButtonOptions);}}});
\ No newline at end of file +{var radioButtonOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TRadioButton(radioButtonOptions);}}});
\ No newline at end of file diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js index d26ad640..e5c05510 100644 --- a/framework/Web/Javascripts/js/debug/ajax.js +++ b/framework/Web/Javascripts/js/debug/ajax.js @@ -302,6 +302,9 @@ Object.extend(Ajax.Request.prototype, if (event == 'Complete')
{
+ if(this.header('X-PRADO-REDIRECT'))
+ document.location.href = this.header('X-PRADO-REDIRECT');
+
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
{
try
@@ -407,10 +410,6 @@ Object.extend(Prado.CallbackRequest, * Page state header name.
*/
PAGESTATE_HEADER : 'X-PRADO-PAGESTATE',
- /**
- * Current requests in progress.
- */
- currentRequest : null,
requestQueue : [],
@@ -553,25 +552,6 @@ Object.extend(Prado.CallbackRequest, },
/**
- * Dispatch a priority request, it will call abortRequestInProgress first.
- */
- dispatchPriorityRequest : function(callback)
- {
- var self = Prado.CallbackRequest;
-
- callback.request = new Ajax.Request(callback.url, callback.options);
- callback.timeout = setTimeout(function()
- {
- //Logger.warn("priority timeout");
- self.abortCurrentRequest();
- },callback.options.RequestTimeOut);
-
- //Logger.info("dispatched "+this.currentRequest)
- self.currentRequest = callback;
- return true;
- },
-
- /**
* Dispatch a normal request, no timeouts or aborting of requests.
*/
dispatchNormalRequest : function(callback)
@@ -584,23 +564,19 @@ Object.extend(Prado.CallbackRequest, /**
* Abort the current priority request in progress.
*/
- abortCurrentRequest : function()
+ tryNextRequest : function()
{
var self = Prado.CallbackRequest;
- var inProgress = self.currentRequest;
- //Logger.info("aborting ... "+inProgress);
- if(inProgress)
+ //Logger.debug('trying next request');
+ if(typeof(self.currentRequest) == 'undefined' || self.currentRequest==null)
{
- clearTimeout(inProgress.timeout);
- self.currentRequest = null;
- //Logger.info("aborted");
- //abort if not ready.
- if(inProgress.request.transport.readyState < 4)
- inProgress.request.transport.abort();
- return self.dispatchQueue();
+ if(self.requestQueue.length > 0)
+ return self.dispatchQueue();
+ //else
+ //Logger.warn('empty queque');
}
- else
- return self.dispatchQueue();
+// else
+ // Logger.warn('current request ' + self.currentRequest.id);
},
/**
@@ -622,51 +598,66 @@ Object.extend(Prado.CallbackRequest, {
if(typeof(Logger) != "undefined")
Logger.warn("Missing page state:"+data);
+// Logger.warn('## bad state: setting current request to null');
+ self.endCurrentRequest();
+ //self.tryNextRequest();
return false;
}
}
+ self.endCurrentRequest();
+ // Logger.warn('## state updated: setting current request to null');
+ // self.tryNextRequest();
return true;
},
enqueue : function(callback)
{
var self = Prado.CallbackRequest;
- if(self.currentRequest==null)
- self.dispatchPriorityRequest(callback);
- else
- self.requestQueue.push(callback);
- //Logger.info("current queque length="+self.requestQueue.length);
+ self.requestQueue.push(callback);
+ //Logger.warn("equeued "+callback.id+", current queque length="+self.requestQueue.length);
+ self.tryNextRequest();
},
dispatchQueue : function()
{
var self = Prado.CallbackRequest;
- //Logger.info("dispatching queque, length="+self.requestQueue.length+" request="+self.currentRequest);
- if(self.requestQueue.length > 0)
+ //Logger.warn("dispatching queque, length="+self.requestQueue.length+" request="+self.currentRequest);
+ var callback = self.requestQueue.shift();
+ self.currentRequest = callback;
+
+ //get data
+ callback.options.postBody = callback._getPostData(),
+
+ callback.request = new Ajax.Request(callback.url, callback.options);
+ callback.timeout = setTimeout(function()
{
- var callback = self.requestQueue.shift();
- //Logger.info("do dispatch request");
- return self.dispatchPriorityRequest(callback);
- }
- return false;
+ //Logger.warn("priority timeout");
+ self.abortRequest(callback.id);
+ },callback.options.RequestTimeOut);
+ //Logger.debug("dispatched "+self.currentRequest.id + " ...")
+ },
+
+ endCurrentRequest : function()
+ {
+ var self = Prado.CallbackRequest;
+ clearTimeout(self.currentRequest.timeout);
+ self.currentRequest=null;
},
abortRequest : function(id)
{
- //Logger.info("abort id="+id);
+ //Logger.warn("abort id="+id);
var self = Prado.CallbackRequest;
- if(self.currentRequest != null && self.currentRequest.id == id)
- self.abortCurrentRequest();
- else
+ if(typeof(self.currentRequest) != 'undefined'
+ && self.currentRequest != null && self.currentRequest.id == id)
{
- var queque = [];
- self.requestQueue.each(function(callback)
- {
- if(callback.id != id)
- queque.push(callback);
- });
- self.requestQueue = queque;
+ var request = self.currentRequest.request;
+ if(request.transport.readyState < 4)
+ request.transport.abort();
+ //Logger.warn('## aborted: setting current request to null');
+ self.endCurrentRequest();
}
+ self.tryNextRequest();
}
})
@@ -676,7 +667,7 @@ Object.extend(Prado.CallbackRequest, Ajax.Responders.register({onComplete : function(request)
{
if(request.options.HasPriority)
- Prado.CallbackRequest.abortCurrentRequest();
+ Prado.CallbackRequest.tryNextRequest();
}});
//Add HTTP exception respones when logger is enabled.
@@ -816,7 +807,7 @@ Prado.CallbackRequest.prototype = //override parameter and postBody options.
Object.extend(this.options,
{
- postBody : this._getPostData(),
+// postBody : this._getPostData(),
parameters : ''
});
@@ -2221,70 +2212,32 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, */
Prado.WebUI.TTimeTriggeredCallback = Base.extend(
{
- count : 0,
- timeout : 0,
-
constructor : function(options)
{
- this.options = Object.extend(
- {
- Interval : 1,
- DecayRate : 0
- }, options || {})
-
- this.onComplete = this.options.onComplete;
+ this.options = Object.extend({ Interval : 1 }, options || {});
Prado.WebUI.TTimeTriggeredCallback.register(this);
},
startTimer : function()
{
- this.options.onComplete = this.onRequestComplete.bind(this);
- this.timer = setTimeout(this.onTimerEvent.bind(this), 200);
+ setTimeout(this.onTimerEvent.bind(this), 100);
+ if(typeof(this.timer) == 'undefined' || this.timer == null)
+ this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);
},
stopTimer : function()
{
- (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
- this.options.onComplete = undefined;
- clearTimeout(this.timer);
- this.timer = undefined;
- this.count = 0;
+ if(typeof(this.timer) != 'undefined')
+ {
+ clearInterval(this.timer);
+ this.timer = null;
+ }
},
onTimerEvent : function()
{
- this.options.params = this.timeout/1000;
var request = new Prado.CallbackRequest(this.options.EventTarget, 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;
- }
- this.timeout = (t + this.options.Interval)*1000;
- this.count++;
- return parseInt(this.timeout);
}
},
//class methods
diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js index aaae6bad..4ab0a415 100644 --- a/framework/Web/Javascripts/js/debug/prado.js +++ b/framework/Web/Javascripts/js/debug/prado.js @@ -3389,9 +3389,11 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl, {
onInit : function(options)
{
+ this.options=options;
if(options['TextMode'] != 'MultiLine')
Event.observe(this.element, "keydown", this.handleReturnKey.bind(this));
- Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
+ if(this.options['AutoPostBack']==true)
+ Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
},
handleReturnKey : function(e)
@@ -3401,8 +3403,19 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl, var target = Event.element(e);
if(target)
{
- Event.fireEvent(target, "change");
- Event.stop(e);
+ if(this.options['AutoPostBack']==true)
+ {
+ Event.fireEvent(target, "change");
+ Event.stop(e);
+ }
+ else
+ {
+ if(this.options['CausesValidation'] && typeof(Prado.Validation) != "undefined")
+ {
+ if(!Prado.Validation.validate(this.options['FormID'], this.options['ValidationGroup'], $(this.options['ID'])))
+ return Event.stop(e);
+ }
+ }
}
}
}
@@ -3504,7 +3517,7 @@ Prado.WebUI.TCheckBoxList = Base.extend( var checkBoxOptions = Object.extend(
{
ID : options.ListID+"_c"+i,
- EventTarget : options.ListID+"$c"+i
+ EventTarget : options.ListName+"$c"+i
}, options);
new Prado.WebUI.TCheckBox(checkBoxOptions);
}
@@ -3520,7 +3533,7 @@ Prado.WebUI.TRadioButtonList = Base.extend( var radioButtonOptions = Object.extend(
{
ID : options.ListID+"_c"+i,
- EventTarget : options.ListID+"$c"+i
+ EventTarget : options.ListName+"$c"+i
}, options);
new Prado.WebUI.TRadioButton(radioButtonOptions);
}
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js index cb787571..e30fb702 100644 --- a/framework/Web/Javascripts/prado/activecontrols3.js +++ b/framework/Web/Javascripts/prado/activecontrols3.js @@ -145,70 +145,32 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, */
Prado.WebUI.TTimeTriggeredCallback = Base.extend(
{
- count : 0,
- timeout : 0,
-
constructor : function(options)
{
- this.options = Object.extend(
- {
- Interval : 1,
- DecayRate : 0
- }, options || {})
-
- this.onComplete = this.options.onComplete;
+ this.options = Object.extend({ Interval : 1 }, options || {});
Prado.WebUI.TTimeTriggeredCallback.register(this);
},
startTimer : function()
{
- this.options.onComplete = this.onRequestComplete.bind(this);
- this.timer = setTimeout(this.onTimerEvent.bind(this), 200);
+ setTimeout(this.onTimerEvent.bind(this), 100);
+ if(typeof(this.timer) == 'undefined' || this.timer == null)
+ this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);
},
stopTimer : function()
{
- (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
- this.options.onComplete = undefined;
- clearTimeout(this.timer);
- this.timer = undefined;
- this.count = 0;
+ if(typeof(this.timer) != 'undefined')
+ {
+ clearInterval(this.timer);
+ this.timer = null;
+ }
},
onTimerEvent : function()
{
- this.options.params = this.timeout/1000;
var request = new Prado.CallbackRequest(this.options.EventTarget, 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;
- }
- this.timeout = (t + this.options.Interval)*1000;
- this.count++;
- return parseInt(this.timeout);
}
},
//class methods
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js index c5402ea4..f540813c 100644 --- a/framework/Web/Javascripts/prado/ajax3.js +++ b/framework/Web/Javascripts/prado/ajax3.js @@ -14,6 +14,9 @@ Object.extend(Ajax.Request.prototype, if (event == 'Complete')
{
+ if(this.header('X-PRADO-REDIRECT'))
+ document.location.href = this.header('X-PRADO-REDIRECT');
+
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
{
try
@@ -119,10 +122,6 @@ Object.extend(Prado.CallbackRequest, * Page state header name.
*/
PAGESTATE_HEADER : 'X-PRADO-PAGESTATE',
- /**
- * Current requests in progress.
- */
- currentRequest : null,
requestQueue : [],
@@ -265,25 +264,6 @@ Object.extend(Prado.CallbackRequest, },
/**
- * Dispatch a priority request, it will call abortRequestInProgress first.
- */
- dispatchPriorityRequest : function(callback)
- {
- var self = Prado.CallbackRequest;
-
- callback.request = new Ajax.Request(callback.url, callback.options);
- callback.timeout = setTimeout(function()
- {
- //Logger.warn("priority timeout");
- self.abortCurrentRequest();
- },callback.options.RequestTimeOut);
-
- //Logger.info("dispatched "+this.currentRequest)
- self.currentRequest = callback;
- return true;
- },
-
- /**
* Dispatch a normal request, no timeouts or aborting of requests.
*/
dispatchNormalRequest : function(callback)
@@ -296,23 +276,19 @@ Object.extend(Prado.CallbackRequest, /**
* Abort the current priority request in progress.
*/
- abortCurrentRequest : function()
+ tryNextRequest : function()
{
var self = Prado.CallbackRequest;
- var inProgress = self.currentRequest;
- //Logger.info("aborting ... "+inProgress);
- if(inProgress)
+ //Logger.debug('trying next request');
+ if(typeof(self.currentRequest) == 'undefined' || self.currentRequest==null)
{
- clearTimeout(inProgress.timeout);
- self.currentRequest = null;
- //Logger.info("aborted");
- //abort if not ready.
- if(inProgress.request.transport.readyState < 4)
- inProgress.request.transport.abort();
- return self.dispatchQueue();
+ if(self.requestQueue.length > 0)
+ return self.dispatchQueue();
+ //else
+ //Logger.warn('empty queque');
}
- else
- return self.dispatchQueue();
+// else
+ // Logger.warn('current request ' + self.currentRequest.id);
},
/**
@@ -334,51 +310,66 @@ Object.extend(Prado.CallbackRequest, {
if(typeof(Logger) != "undefined")
Logger.warn("Missing page state:"+data);
+// Logger.warn('## bad state: setting current request to null');
+ self.endCurrentRequest();
+ //self.tryNextRequest();
return false;
}
}
+ self.endCurrentRequest();
+ // Logger.warn('## state updated: setting current request to null');
+ // self.tryNextRequest();
return true;
},
enqueue : function(callback)
{
var self = Prado.CallbackRequest;
- if(self.currentRequest==null)
- self.dispatchPriorityRequest(callback);
- else
- self.requestQueue.push(callback);
- //Logger.info("current queque length="+self.requestQueue.length);
+ self.requestQueue.push(callback);
+ //Logger.warn("equeued "+callback.id+", current queque length="+self.requestQueue.length);
+ self.tryNextRequest();
},
dispatchQueue : function()
{
var self = Prado.CallbackRequest;
- //Logger.info("dispatching queque, length="+self.requestQueue.length+" request="+self.currentRequest);
- if(self.requestQueue.length > 0)
+ //Logger.warn("dispatching queque, length="+self.requestQueue.length+" request="+self.currentRequest);
+ var callback = self.requestQueue.shift();
+ self.currentRequest = callback;
+
+ //get data
+ callback.options.postBody = callback._getPostData(),
+
+ callback.request = new Ajax.Request(callback.url, callback.options);
+ callback.timeout = setTimeout(function()
{
- var callback = self.requestQueue.shift();
- //Logger.info("do dispatch request");
- return self.dispatchPriorityRequest(callback);
- }
- return false;
+ //Logger.warn("priority timeout");
+ self.abortRequest(callback.id);
+ },callback.options.RequestTimeOut);
+ //Logger.debug("dispatched "+self.currentRequest.id + " ...")
+ },
+
+ endCurrentRequest : function()
+ {
+ var self = Prado.CallbackRequest;
+ clearTimeout(self.currentRequest.timeout);
+ self.currentRequest=null;
},
abortRequest : function(id)
{
- //Logger.info("abort id="+id);
+ //Logger.warn("abort id="+id);
var self = Prado.CallbackRequest;
- if(self.currentRequest != null && self.currentRequest.id == id)
- self.abortCurrentRequest();
- else
+ if(typeof(self.currentRequest) != 'undefined'
+ && self.currentRequest != null && self.currentRequest.id == id)
{
- var queque = [];
- self.requestQueue.each(function(callback)
- {
- if(callback.id != id)
- queque.push(callback);
- });
- self.requestQueue = queque;
+ var request = self.currentRequest.request;
+ if(request.transport.readyState < 4)
+ request.transport.abort();
+ //Logger.warn('## aborted: setting current request to null');
+ self.endCurrentRequest();
}
+ self.tryNextRequest();
}
})
@@ -388,7 +379,7 @@ Object.extend(Prado.CallbackRequest, Ajax.Responders.register({onComplete : function(request)
{
if(request.options.HasPriority)
- Prado.CallbackRequest.abortCurrentRequest();
+ Prado.CallbackRequest.tryNextRequest();
}});
//Add HTTP exception respones when logger is enabled.
@@ -528,7 +519,7 @@ Prado.CallbackRequest.prototype = //override parameter and postBody options.
Object.extend(this.options,
{
- postBody : this._getPostData(),
+// postBody : this._getPostData(),
parameters : ''
});
diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js index c26026ae..97969f87 100644 --- a/framework/Web/Javascripts/prado/controls.js +++ b/framework/Web/Javascripts/prado/controls.js @@ -137,9 +137,11 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl, {
onInit : function(options)
{
+ this.options=options;
if(options['TextMode'] != 'MultiLine')
Event.observe(this.element, "keydown", this.handleReturnKey.bind(this));
- Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
+ if(this.options['AutoPostBack']==true)
+ Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
},
handleReturnKey : function(e)
@@ -149,8 +151,19 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl, var target = Event.element(e);
if(target)
{
- Event.fireEvent(target, "change");
- Event.stop(e);
+ if(this.options['AutoPostBack']==true)
+ {
+ Event.fireEvent(target, "change");
+ Event.stop(e);
+ }
+ else
+ {
+ if(this.options['CausesValidation'] && typeof(Prado.Validation) != "undefined")
+ {
+ if(!Prado.Validation.validate(this.options['FormID'], this.options['ValidationGroup'], $(this.options['ID'])))
+ return Event.stop(e);
+ }
+ }
}
}
}
@@ -252,7 +265,7 @@ Prado.WebUI.TCheckBoxList = Base.extend( var checkBoxOptions = Object.extend(
{
ID : options.ListID+"_c"+i,
- EventTarget : options.ListID+"$c"+i
+ EventTarget : options.ListName+"$c"+i
}, options);
new Prado.WebUI.TCheckBox(checkBoxOptions);
}
@@ -268,7 +281,7 @@ Prado.WebUI.TRadioButtonList = Base.extend( var radioButtonOptions = Object.extend(
{
ID : options.ListID+"_c"+i,
- EventTarget : options.ListID+"$c"+i
+ EventTarget : options.ListName+"$c"+i
}, options);
new Prado.WebUI.TRadioButton(radioButtonOptions);
}
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 3a6d0aa3..3b8c0842 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -81,7 +81,7 @@ class THttpResponse extends TModule implements ITextWriter * @var THttpResponseAdapter adapter.
*/
private $_adapter;
-
+
/**
* Destructor.
* Flushes any existing content in buffer.
@@ -91,7 +91,7 @@ class THttpResponse extends TModule implements ITextWriter //if($this->_bufferOutput)
// @ob_end_flush();
}
-
+
/**
* @param THttpResponseAdapter response adapter
*/
@@ -99,7 +99,7 @@ class THttpResponse extends TModule implements ITextWriter {
$this->_adapter=$adapter;
}
-
+
/**
* @return THttpResponseAdapter response adapter, null if not exist.
*/
@@ -107,7 +107,7 @@ class THttpResponse extends TModule implements ITextWriter {
return $this->_adapter;
}
-
+
/**
* @return boolean true if adapter exists, false otherwise.
*/
@@ -250,7 +250,7 @@ class THttpResponse extends TModule implements ITextWriter {
echo $str;
}
-
+
/**
* Sends a file back to user.
* Make sure not to output anything else after calling this method.
@@ -314,6 +314,19 @@ class THttpResponse extends TModule implements ITextWriter */
public function redirect($url)
{
+ if($this->getHasAdapter())
+ $this->_adapter->httpRedirect($url);
+ else
+ $this->httpRedirect($url);
+ }
+
+ /**
+ * Redirect the browser to another URL and exists the current application.
+ * @param string URL to be redirected to. If the URL is a relative one, the base URL of
+ * the current request will be inserted at the beginning.
+ */
+ public function httpRedirect($url)
+ {
if(!$this->getApplication()->getRequestCompleted())
$this->getApplication()->onEndRequest();
if($url[0]==='/')
@@ -342,7 +355,7 @@ class THttpResponse extends TModule implements ITextWriter else
$this->flushContent();
}
-
+
/**
* Outputs the buffered content, sends content-type and charset header.
*/
@@ -351,7 +364,7 @@ class THttpResponse extends TModule implements ITextWriter Prado::trace("Flushing output",'System.Web.THttpResponse');
$this->sendContentTypeHeader();
if($this->_bufferOutput)
- ob_flush();
+ ob_flush();
}
/**
@@ -474,7 +487,7 @@ class THttpResponse extends TModule implements ITextWriter else
return $this->createNewHtmlWriter($type, $this);
}
-
+
/**
* Create a new html writer intance.
* @param string type of HTML writer to be created.
diff --git a/framework/Web/THttpResponseAdapter.php b/framework/Web/THttpResponseAdapter.php index beb585d4..8a1c86bb 100644 --- a/framework/Web/THttpResponseAdapter.php +++ b/framework/Web/THttpResponseAdapter.php @@ -12,7 +12,7 @@ /** * THttpResponseAdapter class. - * + * * THttpResponseAdapter allows the base http response class to change behaviour * without change the class hierachy. * @@ -27,7 +27,7 @@ class THttpResponseAdapter extends TApplicationComponent * @var THttpResponse the response object the adapter is attached. */ private $_response; - + /** * Constructor. Attach a response to be adapted. * @param THttpResponse the response object the adapter is to attach to. @@ -36,7 +36,7 @@ class THttpResponseAdapter extends TApplicationComponent { $this->_response=$response; } - + /** * @return THttpResponse the response object adapted. */ @@ -44,7 +44,7 @@ class THttpResponseAdapter extends TApplicationComponent { return $this->_response; } - + /** * This method is invoked when the response flushes the content and headers. * Default implementation calls the attached response flushContent method. @@ -53,7 +53,16 @@ class THttpResponseAdapter extends TApplicationComponent { $this->_response->flushContent(); } - + + /** + * This method is invoked when the response is to redirect to another page. + * @param string new url to redirect to. + */ + public function httpRedirect($url) + { + $this->_response->httpRedirect($url); + } + /** * This method is invoked when a new HtmlWriter needs to be created. * Default implementation calls the attached response createNewHtmlWriter method. diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php index 019c002c..9b30fffc 100644 --- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php +++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php @@ -93,7 +93,7 @@ class TActiveLinkButton extends TLinkButton implements IActiveControl, ICallback { parent::setText($value); if($this->getActiveControl()->canUpdateClientSide()) - $this->getPage()->getCallbackClient()->replaceContent($this, $value); + $this->getPage()->getCallbackClient()->update($this, $value); } /** diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 2df19053..514b6880 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -46,6 +46,11 @@ class TActivePageAdapter extends TControlAdapter const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE';
/**
+ * Callback redirect url header name.
+ */
+ const CALLBACK_REDIRECT = 'X-PRADO-REDIRECT';
+
+ /**
* @var ICallbackEventHandler callback event handler.
*/
private $_callbackEventTarget;
@@ -112,7 +117,21 @@ class TActivePageAdapter extends TControlAdapter public function renderCallbackResponse($writer)
{
Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
- $this->renderResponse($writer);
+ if(($url = $this->getResponse()->getAdapter()->getRedirectedUrl())===null)
+ $this->renderResponse($writer);
+ else
+ $this->redirect($url);
+ }
+
+ /**
+ * Redirect url on the client-side using javascript.
+ * @param string new url to load.
+ */
+ protected function redirect($url)
+ {
+ if(!$this->getApplication()->getRequestCompleted())
+ $this->getApplication()->onEndRequest();
+ $this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url);
}
/**
diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index a886e732..07fa652b 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -36,18 +36,20 @@ Prado::using('System.Web.UI.ActiveControls.TActiveTextBox'); * other properties of the repeater can be access via the {@link getSuggestions Suggestions}
* property (e.g. they can be set in the .page templates).
*
- * To return the list of suggestions back to the browser, in your {@link onSuggestion OnSuggestion}
- * event handler, do
+ * To return the list of suggestions back to the browser, supply a non-empty data source
+ * and call databind. For example,
* <code>
* function autocomplete_suggestion($sender, $param)
* {
* $token = $param->getCallbackParameter(); //the partial word to match
* $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
* $sender->dataBind();
- * $sender->render($param->getNewWriter()); //sends suggestion back to browser.
* }
* </code>
*
+ * The suggestion will be rendered when the {@link dataBind()} method is called
+ * <strong>during a callback request</strong>.
+ *
* TAutoComplete allows multiple suggestions within one textbox with each
* word or phrase separated by any characters specified in the
* {@link setSeparator Separator} property. The {@link setFrequency Frequency}
@@ -169,6 +171,17 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer }
/**
+ * Overrides parent implementation. Callback {@link renderSuggestions()} when
+ * page's IsCallback property is true.
+ */
+ public function dataBind()
+ {
+ parent::dataBind();
+ if($this->getPage()->getIsCallback())
+ $this->renderSuggestions($this->getResponse()->createHtmlWriter());
+ }
+
+ /**
* @return TPanel suggestion results panel.
*/
public function getResultPanel()
@@ -232,24 +245,21 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer }
/**
- * Flush and returns the suggestions content back to the browser client.
+ * Renders the suggestions during a callback respones.
* @param THtmlWriter the renderer.
*/
- public function render($writer)
+ public function renderCallback($writer)
{
- if(!$this->getPage()->getIsCallback())
- parent::render($writer);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->renderSuggestions($writer);
+ $this->renderSuggestions($writer);
}
/**
* Renders the suggestions repeater.
* @param THtmlWriter the renderer.
*/
- protected function renderSuggestions($writer)
+ public function renderSuggestions($writer)
{
- if($this->getSuggestions()->getItems()->getCount() > 0)
+ if($this->getActiveControl()->canUpdateClientSide())
{
$this->getSuggestions()->render($writer);
$boundary = $writer->getWriter()->getBoundary();
diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php index 922e6cc6..6e3fb01e 100755 --- a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php +++ b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php @@ -37,6 +37,8 @@ class TCallbackResponseAdapter extends THttpResponseAdapter */ private $_data; + private $_redirectUrl=null; + /** * Returns a new instance of THtmlWriter. * An instance of TCallbackResponseWriter is created to hold the content. @@ -75,6 +77,25 @@ class TCallbackResponseAdapter extends THttpResponseAdapter { return $this->_data; } + + /** + * Delay the redirect until we process the rest of the page. + * @param string new url to redirect to. + */ + public function httpRedirect($url) + { + if($url[0]==='/') + $url=$this->getRequest()->getBaseUrl().$url; + $this->_redirectUrl=str_replace('&','&',$url); + } + + /** + * @return string new url for callback response to redirect to. + */ + public function getRedirectedUrl() + { + return $this->_redirectUrl; + } } /** diff --git a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php index 10923d03..45e33f81 100644 --- a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php @@ -25,11 +25,6 @@ Prado::using('System.Web.UI.ActiveControls.TCallback'); * {@link stopTimer()}. The timer can be automatically started when * {@link setStartTimerOnLoad StartTimerOnLoad} is true. * - * The intervals between each request can be increased when the browser is inactive - * by changing the {@link setDecayRate DecayRate} to a positive number. The - * default decay rate, {@link setDecayType DecayType}, is linear and can be changed to - * 'Exponential', 'Linear', 'Quadratic' or 'Cubic'. - * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @version $Id$ * @package System.Web.UI.ActiveControls @@ -57,44 +52,6 @@ class TTimeTriggeredCallback extends TCallback } /** - * Gets the decay rate between callbacks. Default is 0; - * @return float decay rate between callbacks. - */ - public function getDecayRate() - { - return $this->getViewState('Decay', 0); - } - - /** - * Sets the decay rate between callback. Default is 0; - * @param float decay rate between callbacks. - */ - public function setDecayRate($value) - { - $decay = TPropertyValue::ensureFloat($value); - if($decay < 0) - throw new TConfigurationException('callback_decay_be_not_negative', $this->getID()); - $this->setViewState('Decay', $decay); - } - - /** - * @param string Decay type, allows 'Exponential', 'Linear', 'Quadratic' and 'Cubic'. Default is 'Linear'. - */ - public function setDecayType($value) - { - $this->setViewState('DecayType', TPropertyValue::ensureEnum($value, - 'Exponential', 'Linear', 'Quadratic', 'Cubic'), 'Linear'); - } - - /** - * @return string decay type, default is 'Linear', valid types are 'Exponential', 'Linear', 'Quadratic' and 'Cubic'. - */ - public function getDecayType() - { - return $this->getViewState('DecayType', 'Linear'); - } - - /** * Registers the javascript code to start the timer. */ public function startTimer() @@ -121,7 +78,7 @@ class TTimeTriggeredCallback extends TCallback */ public function setStartTimerOnLoad($value) { - $this->setViewState('StartTimerOnLoad', + $this->setViewState('StartTimerOnLoad', TPropertyValue::ensureBoolean($value), false); } @@ -141,8 +98,6 @@ class TTimeTriggeredCallback extends TCallback $options['ID'] = $this->getClientID(); $options['EventTarget']= $this->getUniqueID(); $options['Interval'] = $this->getInterval(); - $options['DecayRate'] = $this->getDecayRate(); - $options['DecayType'] = $this->getDecayType(); return $options; } diff --git a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php index 3ec830b8..e0320c6b 100644 --- a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php @@ -15,10 +15,8 @@ *
* Observes the value with {@link setPropertyName PropertyName} of a
* control with {@link setControlID ControlID}. Changes to the observed
- * property value will trigger a new callback request. The values are
- * observed using a {@link setPollingInterval PollingInterval} (in seconds).
- * That is, the property is checked for changes every
- * {@link setPollingInterval PollingInterval} seconds.
+ * property value will trigger a new callback request. The property value is checked
+ * for changes every{@link setInterval Interval} seconds.
*
* A {@link setDecayRate DecayRate} can be set to increase the polling
* interval linearly if no changes are observed. Once a change is
@@ -53,12 +51,20 @@ class TValueTriggeredCallback extends TTriggeredCallback * Default is 1 second.
* @param float polling interval in seconds.
*/
- public function setPollingInterval($value)
+ public function setInterval($value)
{
$this->setViewState('Interval', TPropertyValue::ensureFloat($value), 1);
}
/**
+ * @return float polling interval, 1 second default.
+ */
+ public function getInterval()
+ {
+ return $this->getViewState('Interval', 1);
+ }
+
+ /**
* Gets the decay rate between callbacks. Default is 0;
* @return float decay rate between callbacks.
*/
@@ -80,21 +86,13 @@ class TValueTriggeredCallback extends TTriggeredCallback }
/**
- * @return float polling interval, 1 second default.
- */
- public function getPollingInterval()
- {
- return $this->getViewState('Interval', 1);
- }
-
- /**
* @return array list of timer options for client-side.
*/
protected function getTriggerOptions()
{
$options = parent::getTriggerOptions();
$options['PropertyName'] = $this->getPropertyName();
- $options['Interval'] = $this->getPollingInterval();
+ $options['Interval'] = $this->getInterval();
$options['Decay'] = $this->getDecayRate();
return $options;
}
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index 588830f0..e8ad92db 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -156,7 +156,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable $writer->addAttribute('disabled','disabled');
if($isEnabled
&& $this->getEnableClientScript()
- && $this->getAutoPostBack()
+ && ( $this->getAutoPostBack() || $textMode===TTextBoxMode::SingleLine)
&& $page->getClientSupportsJavaScript())
{
$this->renderClientControlScript($writer);
@@ -192,6 +192,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable {
$options['ID'] = $this->getClientID();
$options['EventTarget'] = $this->getUniqueID();
+ $options['AutoPostBack'] = $this->getAutoPostBack();
$options['CausesValidation'] = $this->getCausesValidation();
$options['ValidationGroup'] = $this->getValidationGroup();
$options['TextMode'] = $this->getTextMode();
|