Wicket
  1. Wicket
  2. WICKET-4257

Ajax indicator getting stuck when button is pressed multiple times

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.19
    • Fix Version/s: 1.4.20, 1.5.5
    • Component/s: None
    • Labels:
      None

      Description

      http://apache-wicket.1842946.n4.nabble.com/Ajax-busy-indicator-getting-stuck-td4082837.html

      I have added a global ajax indicator to all my pages by having all
      pages (through a TemplatePage superclass) implement the
      IAjaxIndicatorAware interface.

      Generally it works, but I have noticed that it is quite easy to get
      the ajax indicator stuck spinning indefinitely, by issuing many ajax
      calls quickly the one after the other. For example if I press an ajax
      button multiple times quickly the busy indicator gets stuck.
      It seems as if the Wicket.show(hide)Incrementally js functions lose
      count of ajax requests and the busy indicator is never actually
      hidden.

      With a little reverse engineering I noticed that maybe one of the
      cases this happens is this: an ajax button is pressed,
      showIncrementally is executed, but the actual ajax request is
      postponed because its channel is busy. When the time comes to actually
      execute the request, the request is stopped because of precondition
      check, and thus hideIncrementally is never called. This loses the
      count. A fix might be to call hideIncrementally when the ajax request
      precondition is not met. As to why the precondition is not met, I am
      guessing it's because the previous ajax request did DOM replacement in
      a way that the precondition of the queued request is no longer met.

      1. ajax-indicator.rar
        9 kB
        Nazaret Kazarian

        Issue Links

          Activity

          Martin Grigorov made changes -
          Link This issue is related to WICKET-4364 [ WICKET-4364 ]
          Martin Grigorov made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Martin Grigorov [ mgrigorov ]
          Fix Version/s 1.4.20 [ 12318545 ]
          Fix Version/s 1.5.5 [ 12319052 ]
          Resolution Fixed [ 1 ]
          Hide
          Martin Grigorov added a comment -

          Fixed.
          Now if the precondition doesn't match and there is an indicator then it will be decremented.

          Show
          Martin Grigorov added a comment - Fixed. Now if the precondition doesn't match and there is an indicator then it will be decremented.
          Hide
          Marc Nuri added a comment -

          The bug happens whenever the submitlink is double clicked, as a workaround you can override AjaxSubmitLink with the following code to temporarily disable onclick until the first event is totally processed:

          @Override
          protected IAjaxCallDecorator getAjaxCallDecorator() {
          return new AjaxCallDecorator() {

          @Override
          public CharSequence decorateScript(Component c, CharSequence script) {
          return String.format(
          //Store the old function in onclick_
          "this.onclick_disabled=this.onclick;"
          //Substitute onclick function
          + " this.onclick=function()

          { return false; }

          ;%s", script);
          }

          @Override
          public CharSequence decorateOnSuccessScript(Component c, CharSequence script)

          { return String.format( //Restore old function "if (typeof(this.onclick_disabled) != 'undefined') this.onclick=this.onclick_disabled;%s", script); }

          @Override
          public CharSequence decorateOnFailureScript(Component c, CharSequence script) { return String.format( //Restore old function "if (typeof(this.onclick_disabled) != 'undefined') this.onclick=this.onclick_disabled;%s", script); }

          };
          }

          Show
          Marc Nuri added a comment - The bug happens whenever the submitlink is double clicked, as a workaround you can override AjaxSubmitLink with the following code to temporarily disable onclick until the first event is totally processed: @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxCallDecorator() { @Override public CharSequence decorateScript(Component c, CharSequence script) { return String.format( //Store the old function in onclick_ "this.onclick_disabled=this.onclick;" //Substitute onclick function + " this.onclick=function() { return false; } ;%s", script); } @Override public CharSequence decorateOnSuccessScript(Component c, CharSequence script) { return String.format( //Restore old function "if (typeof(this.onclick_disabled) != 'undefined') this.onclick=this.onclick_disabled;%s", script); } @Override public CharSequence decorateOnFailureScript(Component c, CharSequence script) { return String.format( //Restore old function "if (typeof(this.onclick_disabled) != 'undefined') this.onclick=this.onclick_disabled;%s", script); } }; }
          Hide
          Marc Nuri added a comment -

          I'm experiencing the problem 1.5.4 and 1.5.3 too.

          Show
          Marc Nuri added a comment - I'm experiencing the problem 1.5.4 and 1.5.3 too.
          Hide
          Marc Nuri added a comment -

          I have the same issue.
          If an AjaxSubmitLink is pressed and the request is postponed the AjaxIndicator remains visible when the request is finally completed.
          This only happens with AjaxSubmitLink.

          Show
          Marc Nuri added a comment - I have the same issue. If an AjaxSubmitLink is pressed and the request is postponed the AjaxIndicator remains visible when the request is finally completed. This only happens with AjaxSubmitLink.
          Nazaret Kazarian made changes -
          Field Original Value New Value
          Attachment ajax-indicator.rar [ 12504870 ]
          Hide
          Nazaret Kazarian added a comment -

          Quickstart reproducing the problem.

          Show
          Nazaret Kazarian added a comment - Quickstart reproducing the problem.
          Nazaret Kazarian created issue -

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Nazaret Kazarian
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development