[richfaces-svn-commits] JBoss Rich Faces SVN: r12413 - trunk/framework/impl/src/main/javascript/ajaxjsf.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Jan 23 18:42:05 EST 2009


Author: nbelaevski
Date: 2009-01-23 18:42:05 -0500 (Fri, 23 Jan 2009)
New Revision: 12413

Modified:
   trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
   trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
https://jira.jboss.org/jira/browse/RF-5788

Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js	2009-01-23 19:42:25 UTC (rev 12412)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js	2009-01-23 23:42:05 UTC (rev 12413)
@@ -54,10 +54,25 @@
  	this._request.onreadystatechange =  function(){
  				if(window.document.documentElement != _this._documentElement){
           			LOG.warn("Page for current request have been unloaded - abort processing" );
- 					_this.abort();
+
+          			if(!_this._status_stopped) {
+          				//end status early
+ 						A4J.AJAX.status(_this.containerId, _this.options.status, false);
+          				_this._status_stopped = true;
+          			}
+          			
+          			_this.abort();
+          			
  					return;
  				};
+ 				
  				if(_this._aborted){
+ 					if (_this._request.readyState == 4) {
+ 					    //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 );
@@ -147,24 +162,14 @@
 	},
 	
 	abort: function(){
-   			if(!this._aborted){
-		     A4J.AJAX.status(this.containerId,this.options.status,false);
-		     if(typeof(A4J.AJAX.onAbort) == "function"){
-   				A4J.AJAX.onAbort(this);
-		     }
-   			}
-		this._aborted=true;
-		if(this._request){
-			try{
-//				this._request.abort();
-				if(this._timeoutID){
-					window.clearTimeout(this._timeoutID);
-				}
-			} catch (e){
-				LOG.warn("Exception for abort current request "+e.Message);
+		if(!this._aborted){
+			if(typeof(A4J.AJAX.onAbort) == "function"){
+				A4J.AJAX.onAbort(this);
 			}
 		}
+		this._aborted=true;
 	},
+
 	getResponseText : function(){
 		try {
 			return this._request.responseText;
@@ -1187,11 +1192,15 @@
 	    	  }, 0)
 	      }
 
-	     if (request.shouldNotifyQueue && request.queue) {
-	    	 request.queue.pop();
-	     }
+	     A4J.AJAX.popQueue(request);
     };
 
+A4J.AJAX.popQueue = function(request) {
+	if (request.shouldNotifyQueue && request.queue) {
+		request.queue.pop();
+	}
+};    
+    
 A4J.AJAX.getCursorPos =	function(inp){
 
 		   if(inp.selectionEnd != null)

Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js	2009-01-23 19:42:25 UTC (rev 12412)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js	2009-01-23 23:42:05 UTC (rev 12413)
@@ -65,13 +65,16 @@
 			},
 			
 			abort: function() {
-				if (this.request) {
+				if (this.request && !this.aborted) {
 					//tell request not to notify queue after its processing finished
 					//request.queue = undefined 
 					//is not ok for this case because user might want to obtain queue in any event handler
-					this.request.shouldNotifyQueue = false;
+
+					//RF-5788
+					this.aborted = true;
+					//this.request.shouldNotifyQueue = false;
 					this.request.abort();
-					this.request = undefined;
+					//this.request = undefined;
 				}
 			},
 			
@@ -180,6 +183,10 @@
 			return this.queueOptions.size;
 		},
 		
+		isFull: function() {
+			return this.getSize() == this.getMaximumSize();
+		},
+		
 		getSizeExceededBehavior: function() {
 			var policy = this.queueOptions.sizeExceededBehavior;
 			if (!policy) {
@@ -224,14 +231,21 @@
 					if (last.request) {
 						LOG.debug("Request has already beeen sent to server");
 						if (entry.isIgnoreDupResponses()) {
-							LOG.debug("Duplicate responses ignore requested, queue will abort current request");
+							LOG.debug("Duplicate responses ignore requested");
 
-							last.abort();
+							if (!this.isFull()) {
+								last.abort();
+								
+								LOG.debug("Response for the current request will be ignored");
+								
+								/* Change for - RF-5788 - wait current request to complete even if ignore duplicate is true
+								//remove last (that is actually first) from queue - will be safer to do that in LinkedList
+								this.dequeue();
+								*/
+							} else {
+								LOG.debug("Queue is full, cannot set to ignore response for the current request");
+							}
 							
-							LOG.debug("Current request in queue '" + this.name + "' has been aborted");
-							
-							//remove last (that is actually first) from queue - will be safer to do that in LinkedList
-							this.dequeue();
 						}
 					} else {
 						LOG.debug("Combine similar requests and reset timer");
@@ -253,7 +267,7 @@
 			}
 			
 			if (!handled) {
-				if (this.queueOptions.size == this.items.length) {
+				if (this.isFull()) {
 					LOG.debug("Queue '" + this.name + "' is currently full")
 					
 					var b = this.getSizeExceededBehavior();




More information about the richfaces-svn-commits mailing list