Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2401

AJAX indicator turns off when calls overlap

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.0
    • 1.4.11, 1.5-M2.1
    • wicket
    • None

    Description

      As discussed here http://www.nabble.com/Ajax-indicator-turning-off-td24655744.html

      Overlapping AJAX calls result in the indicator being turned off when the first call returns. This patch keeps a count property directly on the HTMLElement so when the element goes out of scope the count does not need to be removed. Each AJAX call increments the counter and each return decrements the counter.

      Index: src/main/java/org/apache/wicket/ajax/wicket-ajax.js
      ===================================================================
      — src/main/java/org/apache/wicket/ajax/wicket-ajax.js (revision 797714)
      +++ src/main/java/org/apache/wicket/ajax/wicket-ajax.js (working copy)
      @@ -2214,3 +2214,31 @@
      e.style.display = "none";
      }
      }
      +
      +function wicketIncrementDisplay(id) {
      + var e=wicketGet(id);
      + if (typeof(e.wicketDisplayCount) =="undefined")

      { + e.wicketDisplayCount = 1; + }

      else

      { + e.wicketDisplayCount++; + }

      +
      + if (e.wicketDisplayCount > 0)

      { + e.style.display = ""; + }

      +}
      +
      +function wicketDecrementDisplay(id) {
      + var e=wicketGet(id);
      + if (typeof(e.wicketDisplayCount) =="undefined")

      { + e.wicketDisplayCount = 0; + }

      else

      { + e.wicketDisplayCount--; + }

      +
      + if (e.wicketDisplayCount <= 0)

      { + e.style.display = "none"; + }

      +}
      +
      +
      Index: src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
      ===================================================================
      — src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java (revision 797714)
      +++ src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java (working copy)
      @@ -183,7 +183,7 @@

      if (!Strings.isEmpty(indicatorId))

      { - String hide = ";wicketHide('" + indicatorId + "');"; + String hide = ";wicketDecrementDisplay('" + indicatorId + "');"; success = success + hide; failure = failure + hide; }

      @@ -240,7 +240,7 @@

      if (!Strings.isEmpty(indicatorId))

      { - call = new AppendingStringBuffer("wicketShow('").append(indicatorId) + call = new AppendingStringBuffer("wicketIncrementDisplay('").append(indicatorId) .append("');") .append(call); }

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            jdpatterson John Patterson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: