Author: alexsmirnov
Date: 2007-10-03 19:01:14 -0400 (Wed, 03 Oct 2007)
New Revision: 3242
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
fix RF-1061
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-10-03 22:56:18 UTC
(rev 3241)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-10-03 23:01:14 UTC
(rev 3242)
@@ -15,6 +15,8 @@
*/
A4J.AJAX.XMLHttpRequest = function(query){
this._query = query;
+ // Store document element, to check page replacement.
+ this._documentElement = window.document.documentElement;
};
A4J.AJAX.XMLHttpRequest.prototype = {
@@ -28,7 +30,9 @@
_onerror : function(req,status,message) {
// Status not 200 - error !
// window.alert(message);
+ if(status !=599 && req.getResponseText()){
A4J.AJAX.replacePage(req);
+ }
},
onfinish : null,
options : {},
@@ -36,7 +40,7 @@
form : null,
_request : null,
_aborted : false,
-
+ _documentElement : null,
setRequestTimeout : function(timeout){
this._timeout = timeout;
},
@@ -47,6 +51,11 @@
this._request = new XMLHttpRequest();
var _this = this;
this._request.onreadystatechange = function(){
+ if(window.document.documentElement != _this._documentElement){
+ LOG.warn("Page for current request have been unloaded - abort
processing" );
+ _this.abort();
+ return;
+ };
if(_this._aborted){return;};
LOG.debug("Reqest state : "+_this._request.readyState );
if (_this._request.readyState == 4 ) {
@@ -60,8 +69,8 @@
requestStatus = _this._request.status;
requestStatusText = _this._request.statusText;
} catch(e){
- LOG.error("request don't have status code - network problem");
- requestStatus = 501;
+ LOG.error("request don't have status code - network problem,
"+e.message);
+ requestStatus = 599;
requestStatusText = "Network error";
}
if(requestStatus == 200){
@@ -151,7 +160,11 @@
}
},
getResponseText : function(){
- return this._request.responseText;
+ try {
+ return this._request.responseText;
+ } catch(e){
+ return null;
+ }
},
getError : function(){
return this._errorMessage;
@@ -308,7 +321,7 @@
try {
oldnode.innerHTML = "";
} catch(e){
- LOG.error("Error to clear node content by innerHTML");
+ LOG.error("Error to clear node content by innerHTML
"+e.message);
Sarissa.clearChildNodes(oldnode);
}
oldnode.outerHTML = new XMLSerializer().serializeToString(newnode);
@@ -530,7 +543,7 @@
try {
domEvt = A4J.AJAX.CloneObject(evt,false);
} catch(e){
- LOG.warn("Exception on clone event");
+ LOG.warn("Exception on clone event "+e.name +":"+e.message);
}
LOG.debug("Have Event "+domEvt+" with properties: target:
"+domEvt.target+", srcElement: "+domEvt.srcElement+", type:
"+domEvt.type);
}
@@ -784,6 +797,10 @@
A4J.AJAX.replacePage = function(req){
+ if(!req.getResponseText()){
+ LOG.warn("No content in response for replace current page");
+ return;
+ }
LOG.debug("replace all page content with response");
var isIE = _SARISSA_IS_IE;
// maksimkaszynski
Show replies by date