Author: nbelaevski
Date: 2009-02-02 10:45:48 -0500 (Mon, 02 Feb 2009)
New Revision: 12520
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
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 15:09:42 UTC
(rev 12519)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-02-02 15:45:48 UTC
(rev 12520)
@@ -141,6 +141,9 @@
if(this._timeout > 0){
this._timeoutID = window.setTimeout(function(){
LOG.warn("request stopped due to timeout");
+
+ _this._oncomplete_aborted = _this._aborted;
+
if(!_this._aborted){
// A4J.AJAX.status(_this.containerId,_this.options.status,false);
if(typeof(A4J.AJAX.onAbort) == "function"){
@@ -1138,90 +1141,99 @@
*
*/
A4J.AJAX.finishRequest = function(request){
- var options = request.options;
-
- // we can set listener for complete request - for example,
- // it can shedule next request for update page.
- var oncomp;
+ var options = request.options;
- //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;
+ if (!request._oncomplete_aborted) {
+ // we can set listener for complete request - for example,
+ // it can shedule next request for update page.
+ var oncomp;
- var data;
- try {
- data = request.getJSON('_ajax:data');
- } catch (e) {
- LOG.warn("Error reading data from request " + e.message);
- }
-
+ //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;
try {
- var target = null;
- if (event) {
- target = event.target ? event.target : event.srcElement;
+ data = request.getJSON('_ajax:data');
+ } catch (e) {
+ LOG.warn("Error reading data from request " + e.message);
+ }
+
+ try {
+ var target = null;
+ if (event) {
+ target = event.target ? event.target : event.srcElement;
}
- var newscript = Sarissa.getText(oncomp,true);
- var oncomplete = new
Function("request","event","data",newscript);
+ var newscript = Sarissa.getText(oncomp,true);
+ var oncomplete = new
Function("request","event","data",newscript);
oncomplete.call(target,request,event,data);
-
- if (options.queueoncomplete) {
- options.queueoncomplete.call(target, request, event, data);
- }
-
+
+ if (options.queueoncomplete) {
+ options.queueoncomplete.call(target, request, event, data);
+ }
+
} catch (e) {
- LOG.error('Error evaluate oncomplete function '+e.Message);
+ LOG.error('Error evaluate oncomplete function '+e.Message);
}
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);},
- 0);
- } else if (options.oncomplete || options.queueoncomplete){
- LOG.debug( "Call local oncomplete function after processing updates" );
- window.setTimeout(function(){
- var event = request.domEvt;
-
- 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);
- }
-
- if (options.queueoncomplete) {
- options.queueoncomplete(request, event, data);
- }
-
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);},
- 0);
-
- } else {
- LOG.debug( "Processing updates finished, no oncomplete function to
call" );
-
- setTimeout(function() {
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);
- }, 0)
- }
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);},
+ 0);
+ } else if (options.oncomplete || options.queueoncomplete){
+ LOG.debug( "Call local oncomplete function after processing updates" );
+ window.setTimeout(function(){
+ var event = request.domEvt;
- A4J.AJAX.popQueue(request);
- };
+ 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);
+ }
+
+ if (options.queueoncomplete) {
+ options.queueoncomplete(request, event, data);
+ }
+
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);},
+ 0);
+
+ } else {
+ LOG.debug( "Processing updates finished, no oncomplete function to call" );
+
+ setTimeout(function() {
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);
+ }, 0)
+ }
+ } else {
+ LOG.debug("Aborted request, won't call oncomplete at all" );
+
+ setTimeout(function() {
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);
+ }, 0)
+ }
+
+ A4J.AJAX.popQueue(request);
+};
+
A4J.AJAX.popQueue = function(request) {
if (request.shouldNotifyQueue && request.queue) {
request.queue.pop();