OFBiz
  1. OFBiz
  2. OFBIZ-4780

Auto-completer request should be async.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Release Branch 11.04, Trunk
    • Fix Version/s: Release Branch 11.04, Trunk
    • Component/s: framework
    • Labels:
      None

      Description

      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.

      1. OFBIZ-4780.patch
        3 kB
        Deepak Dixit
      2. selectAll.patch
        1 kB
        Deepak Dixit

        Activity

        Hide
        Deepak Dixit added a comment -

        Here is the patch to fix this issue.

        Added LAST_AUTOCOMP_REF global js variable to store the last auto-completer reference (jqXHR). If new ajax request is initiated then abort the LAST_AUTOCOMP_REF if exists and assign current jqXHR as LAST_AUTOCOMP_REF.

        Also skip the RequestHandlerException for ajax call to support abort() method. If we call abort() method on jqXHR then request handler throws Broken pipe exception because request is aborted by client(Browser), to handle this skip the RequestHandlerException for ajax request.

        Show
        Deepak Dixit added a comment - Here is the patch to fix this issue. Added LAST_AUTOCOMP_REF global js variable to store the last auto-completer reference (jqXHR). If new ajax request is initiated then abort the LAST_AUTOCOMP_REF if exists and assign current jqXHR as LAST_AUTOCOMP_REF. Also skip the RequestHandlerException for ajax call to support abort() method. If we call abort() method on jqXHR then request handler throws Broken pipe exception because request is aborted by client(Browser), to handle this skip the RequestHandlerException for ajax request.
        Hide
        Jacques Le Roux added a comment -

        Thanks Deepak,

        This makes sense indeed, your patch is in
        trunk r1308751
        R11.04 r1308752

        Show
        Jacques Le Roux added a comment - Thanks Deepak, This makes sense indeed, your patch is in trunk r1308751 R11.04 r1308752
        Hide
        Deepak Dixit added a comment -

        Thanks Jacques.

        Show
        Deepak Dixit added a comment - Thanks Jacques.
        Hide
        Deepak Dixit added a comment -

        Find one minor issue regarding the pending request count for ajax auto-completer, pending count is used to add and remove the ui-autocomplete-loading class, if we are aborting the request then this count not updated properly and ui-autocomplete-loading class does not remove from the lookup element hence ajax loader image display continuously if response came.

        Show
        Deepak Dixit added a comment - Find one minor issue regarding the pending request count for ajax auto-completer, pending count is used to add and remove the ui-autocomplete-loading class, if we are aborting the request then this count not updated properly and ui-autocomplete-loading class does not remove from the lookup element hence ajax loader image display continuously if response came.
        Hide
        Deepak Dixit added a comment - - edited

        Here is the patch (SelectAll.patch) for the fix.

        Show
        Deepak Dixit added a comment - - edited Here is the patch (SelectAll.patch) for the fix.
        Hide
        Jacques Le Roux added a comment -

        Thanks Deepak,

        Good catch, I forgot the response callback need for cleaning (quoting http://jqueryui.com/demos/autocomplete/#overview-main)

        A response callback, which expects a single argument to contain the data to suggest to the user. This data should be filtered based on the provided term, and can be in any of the formats described above for simple local data (String-Array or Object-Array with label/value/both properties). It's important when providing a custom source callback to handle errors during the request. You must always call the response callback even if you encounter an error. This ensures that the widget always has the correct state.

        Your patch is in
        trunk r1310266
        R11.04 r1310267

        Show
        Jacques Le Roux added a comment - Thanks Deepak, Good catch, I forgot the response callback need for cleaning (quoting http://jqueryui.com/demos/autocomplete/#overview-main ) A response callback, which expects a single argument to contain the data to suggest to the user. This data should be filtered based on the provided term, and can be in any of the formats described above for simple local data (String-Array or Object-Array with label/value/both properties). It's important when providing a custom source callback to handle errors during the request. You must always call the response callback even if you encounter an error. This ensures that the widget always has the correct state. Your patch is in trunk r1310266 R11.04 r1310267
        Hide
        Deepak Dixit added a comment -

        Thanks Jacques

        Show
        Deepak Dixit added a comment - Thanks Jacques

          People

          • Assignee:
            Jacques Le Roux
            Reporter:
            Deepak Dixit
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development