diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2013-10-24 19:16:20 +0200 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2013-11-26 11:42:46 +0100 |
commit | f34d86fc59349c9a8e7ecd3f6b571ea89f8d7295 (patch) | |
tree | 6dda4c90fa4a58b4f35eef7f67fe83bb2c723bec /framework/Web/Javascripts/source/prado/activecontrols/ajax3.js | |
parent | dd49f04ffd14333bdc6d0fed9faed7f67bb0441f (diff) |
More ajax-related porting
Initial implementation of ajax error handling
Fixed ajax modifications of select and checkboxes
Partially ported TJavascriptLogger (used in tests)
Diffstat (limited to 'framework/Web/Javascripts/source/prado/activecontrols/ajax3.js')
-rw-r--r-- | framework/Web/Javascripts/source/prado/activecontrols/ajax3.js | 129 |
1 files changed, 51 insertions, 78 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index 37941fd4..38bc4b7f 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -239,6 +239,24 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { //null) are "timeout", "error", "abort", and "parsererror" if (this.options.onFailure) this.options.onFailure(this,null); + + if(request.status==500) + { + /** + * Server returns 500 exception. Just log it. + */ + var e = request.getResponseHeader(Prado.CallbackRequestManager.ERROR_HEADER); + if (e) + { + json = jQuery.parseJSON(e); + if(typeof(json) == "object") + Logger.error("Callback Server Error "+json.code, this.formatException(json)); + else + Logger.error("Callback Server Error Corrupted"); + } + else + Logger.error("Callback Server Error Unknown",''); + } }, completeHandler: function(request, textStatus) @@ -249,18 +267,51 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { }, + /** + * Uncaught exceptions during callback response. + */ exceptionHandler: function(e) { if (this.options.onException) this.options.onException(this,null); + var msg = ""; + jQuery.each(e, function(item) + { + msg += item.key+": "+item.value+"\n"; + }) + Logger.error('Uncaught Callback Client Exception:', msg); }, + /** + * Formats the exception message for display in console. + */ + formatException : function(e) + { + var msg = e.type + " with message \""+e.message+"\""; + msg += " in "+e.file+"("+e.line+")\n"; + msg += "Stack trace:\n"; + var trace = e.trace; + for(var i = 0; i<trace.length; i++) + { + msg += " #"+i+" "+trace[i].file; + msg += "("+trace[i].line+"): "; + msg += trace[i]["class"]+"->"+trace[i]["function"]+"()"+"\n"; + } + msg += e.version+" "+e.time+"\n"; + return msg; + }, + + /** + * Callback OnSuccess event,logs reponse and data to console. + */ successHandler: function(data, textStatus, request) { if (this.options.onSuccess) this.options.onSuccess(this,null); + Logger.info('HTTP '+request.status+" with response : \n"+data); + this.data = data; var redirectUrl = this.extractContent(Prado.CallbackRequestManager.REDIRECT_HEADER); if (redirectUrl) @@ -692,84 +743,6 @@ Prado.CallbackRequest.addPostLoaders = function(ids) // }, // /** -// * Respond to Prado Callback request exceptions. -// */ -// Exception : -// { -// /** -// * Server returns 500 exception. Just log it. -// */ -// "on500" : function(request, transport, data) -// { -// var e = request.getHeaderData(Prado.CallbackRequest.ERROR_HEADER); -// if (e) -// Logger.error("Callback Server Error "+e.code, this.formatException(e)); -// else -// Logger.error("Callback Server Error Unknown",''); -// }, - -// /** -// * Callback OnComplete event,logs reponse and data to console. -// */ -// 'on200' : function(request, transport, data) -// { -// if(transport.status < 500) -// { -// var msg = 'HTTP '+transport.status+" with response : \n"; -// if(transport.responseText.trim().length >0) -// { -// var f = RegExp('(<!--X-PRADO[^>]+-->)([\\s\\S\\w\\W]*)(<!--//X-PRADO[^>]+-->)',"m"); -// msg += transport.responseText.replace(f,'') + "\n"; -// } -// if(typeof(data)!="undefined" && data != null) -// msg += "Data : \n"+inspect(data)+"\n"; -// data = request.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER); -// if(data && data.length > 0) -// { -// msg += "Actions : \n"; -// data.each(function(action) -// { -// msg += inspect(action)+"\n"; -// }); -// } -// Logger.info(msg); -// } -// }, - -// /** -// * Uncaught exceptions during callback response. -// */ -// onException : function(request,e) -// { -// var msg = ""; -// $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. -// */ -// formatException : function(e) -// { -// var msg = e.type + " with message \""+e.message+"\""; -// msg += " in "+e.file+"("+e.line+")\n"; -// msg += "Stack trace:\n"; -// var trace = e.trace; -// for(var i = 0; i<trace.length; i++) -// { -// msg += " #"+i+" "+trace[i].file; -// msg += "("+trace[i].line+"): "; -// msg += trace[i]["class"]+"->"+trace[i]["function"]+"()"+"\n"; -// } -// msg += e.version+" "+e.time+"\n"; -// return msg; -// } -// }, - -// /** // * Dispatch a normal request, no timeouts or aborting of requests. // */ // dispatchNormalRequest : function(callback) |