Author: jleroux
Date: Tue Apr 3 08:43:17 2012 New Revision: 1308752 URL: http://svn.apache.org/viewvc?rev=1308752&view=rev Log: "Applied fix from trunk for revision: 1308751" ------------------------------------------------------------------------ r1308751 | jleroux | 2012-04-03 10:41:06 +0200 (mar., 03 avr. 2012) | 9 lines A patch from Deepak Dixit for "Auto-completer request should be async." https://issues.apache.org/jira/browse/OFBIZ-4780 Currently auto-completer uses sync call to prepare auto-completer source (result list). Due to this user can't perform any other operation on lookup field and user should have to wait until response came. In general, synchronous requests should never be used because they tend to block the execution of anything else on the page (or even the entire browser UI), which isn't good. Also ajax-loader image not display on google chrome browser due to sync request. Need to use async request for auto-completer. ------------------------------------------------------------------------ Modified: ofbiz/branches/release11.04/ (props changed) ofbiz/branches/release11.04/framework/images/webapp/images/selectall.js ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Propchange: ofbiz/branches/release11.04/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk:r1308751 Modified: ofbiz/branches/release11.04/framework/images/webapp/images/selectall.js URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/images/webapp/images/selectall.js?rev=1308752&r1=1308751&r2=1308752&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/images/webapp/images/selectall.js (original) +++ ofbiz/branches/release11.04/framework/images/webapp/images/selectall.js Tue Apr 3 08:43:17 2012 @@ -17,6 +17,9 @@ * under the License. */ +//Define global variable to store last auto-completer request object (jqXHR). +var LAST_AUTOCOMP_REF = null; + // Check Box Select/Toggle Functions for Select/Toggle All function toggle(e) { @@ -415,8 +418,15 @@ function ajaxAutoCompleter(areaCsvString jQuery.ajax({ url: url, type: "post", - async: false, data: {term : request.term}, + beforeSend: function (jqXHR, settings) { + //If LAST_AUTOCOMP_REF is not null means an existing ajax auto-completer request is in progress, so need to abort them to prevent inconsistent behavior of autocompleter + if (LAST_AUTOCOMP_REF != null) { + var oldRef = LAST_AUTOCOMP_REF; + oldRef.abort(); + } + LAST_AUTOCOMP_REF= jqXHR; + }, success: function(data) { // reset the autocomp field autocomp = undefined; Modified: ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1308752&r1=1308751&r2=1308752&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Tue Apr 3 08:43:17 2012 @@ -855,7 +855,14 @@ public class RequestHandler { try { resp.flushBuffer(); } catch (java.io.IOException e) { - throw new RequestHandlerException("Error flushing response buffer", e); + /*If request is an ajax request and user calls abort() method for on ajax request then skip throwing of RequestHandlerException . + Specially its done for async ajax auto completer call, if we call abort() method on ajax request then its showing broken pipe exception on console, + because request is aborted by client (browser).*/ + if (!"XMLHttpRequest".equals(req.getHeader("X-Requested-With"))) { + throw new RequestHandlerException("Error flushing response buffer", e); + } else { + if (Debug.verboseOn()) Debug.logVerbose("Skip Request Handler Exception for ajax request.", module); + } } String vname = (String) req.getAttribute("_CURRENT_VIEW_"); |
Free forum by Nabble | Edit this page |