[ 
https://issues.apache.org/jira/browse/WICKET-2401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12736093#action_12736093
 ] 

Igor Vaynberg commented on WICKET-2401:
---------------------------------------

this is good for a global indicator, but what if i have indicators for 
individual links/buttons?

then if i press two links their indicators will keep spinning untill the latest 
one finishes - which is undesirable.

> AJAX indicator turns off when calls overlap
> -------------------------------------------
>
>                 Key: WICKET-2401
>                 URL: https://issues.apache.org/jira/browse/WICKET-2401
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.0
>            Reporter: John Patterson
>
> 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);
>               }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to