Author: nbelaevski
Date: 2009-02-02 10:09:42 -0500 (Mon, 02 Feb 2009)
New Revision: 12519
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
https://jira.jboss.org/jira/browse/RF-5849
https://jira.jboss.org/jira/browse/RF-5933
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-02-02 14:30:36 UTC
(rev 12518)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-02-02 15:09:42 UTC
(rev 12519)
@@ -10,6 +10,8 @@
A4J.AJAX = {};
+A4J.AJAX.Stub = function() {};
+
/**
* XMLHttp transport class - incapsulate most of client-specifiv functions for call
server requests.
*/
@@ -66,18 +68,17 @@
return;
};
- if(_this._aborted){
- if (_this._request.readyState == 4) {
+ LOG.debug("Reqest state : "+_this._request.readyState );
+ if (_this._request.readyState == 4 ) {
+ if(_this._aborted){
//this will be true just once for request - no need to track state of status
A4J.AJAX.status(_this.containerId, _this.options.status, false);
A4J.AJAX.popQueue(_this);
- }
-
- return;
- };
- LOG.debug("Reqest state : "+_this._request.readyState );
- if (_this._request.readyState == 4 ) {
- LOG.debug("Reqest end with state 4");
+
+ return;
+ };
+
+ LOG.debug("Reqest end with state 4");
if(_this._timeoutID){
window.clearTimeout(_this._timeoutID);
}
@@ -141,13 +142,17 @@
this._timeoutID = window.setTimeout(function(){
LOG.warn("request stopped due to timeout");
if(!_this._aborted){
- A4J.AJAX.status(_this.containerId,_this.options.status,false);
+// A4J.AJAX.status(_this.containerId,_this.options.status,false);
if(typeof(A4J.AJAX.onAbort) == "function"){
A4J.AJAX.onAbort(_this);
}
}
_this._aborted=true;
+
+ //IE doesn't call onreadystatechange by abort() invocation as other browsers do,
unify this
+ _this._request.onreadystatechange = A4J.AJAX.Stub;
_this._request.abort();
+
if(_this._onerror){
_this._errorMessage = "Request timeout";
_this._onerror(_this,500,_this._errorMessage);
@@ -1137,12 +1142,28 @@
// we can set listener for complete request - for example,
// it can shedule next request for update page.
- var oncomp = request.getElementById('org.ajax4jsf.oncomplete');
+ var oncomp;
+
+ //FIXME: IE doesn't allow to read data from request if it's been aborted
+ //so it's possible that different browsers will follow different branches
+ //of execution for the identical request conditions
+ try {
+ oncomp = request.getElementById('org.ajax4jsf.oncomplete');
+ } catch (e) {
+ LOG.warn("Error reading oncomplete from request " + e.message);
+ }
+
if(oncomp) {
LOG.debug( "Call request oncomplete function after processing updates"
);
window.setTimeout(function(){
var event = request.domEvt;
- var data = request.getJSON('_ajax:data');
+
+ var data;
+ try {
+ data = request.getJSON('_ajax:data');
+ } catch (e) {
+ LOG.warn("Error reading data from request " + e.message);
+ }
try {
var target = null;
@@ -1169,8 +1190,14 @@
LOG.debug( "Call local oncomplete function after processing updates" );
window.setTimeout(function(){
var event = request.domEvt;
- var data = request.getJSON('_ajax:data');
+ var data;
+ try {
+ data = request.getJSON('_ajax:data');
+ } catch (e) {
+ LOG.warn("Error reading data from request " + e.message);
+ }
+
if (options.oncomplete) {
options.oncomplete(request, event, data);
}