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

ASF GitHub Bot commented on WICKET-6055:
----------------------------------------

Github user svenmeier commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/151#discussion_r48385474
  
    --- Diff: 
wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxLazyLoadPanel.java
 ---
    @@ -187,8 +237,56 @@ public Component getLoadingComponent(final String 
markupId)
        {
                IRequestHandler handler = new ResourceReferenceRequestHandler(
                        AbstractDefaultAjaxBehavior.INDICATOR);
    -           return new Label(markupId, "<img alt=\"Loading...\" src=\"" +
    -                   RequestCycle.get().urlFor(handler) + 
"\"/>").setEscapeModelStrings(false);
    +           return new Label(markupId,
    +                   "<img alt=\"Loading...\" src=\"" + 
RequestCycle.get().urlFor(handler) + "\"/>")
    +                           .setEscapeModelStrings(false);
        }
     
    +   /**
    +    * Factory method for creating the lazily loaded component that 
replaces the spinner after
    +    * {@link #isReadyForReplacement()} returns {@code true}. You may call 
setRenderBodyOnly(true)
    +    * on this component if you need the body only.
    +    * 
    +    * @param markupId
    +    *            The components markupid.
    +    * @return The component that must be lazy created.
    +    */
    +   public abstract Component getLazyLoadComponent(String markupId);
    +
    +   /**
    +    * The AJAX timer for updating the AjaxLazyLoadPanel. Is designed to be 
a page-local singleton
    +    * keeping track of multiple LazyLoadPanels using reference counting.
    +    */
    +   private class AjaxLazyLoadTimer extends AbstractAjaxTimerBehavior
    +   {
    +           private static final long serialVersionUID = 1L;
    +
    +           private int lazyLoadPanels = 0;
    --- End diff --
    
    Counting all loading panels might be problematic: What if one (or one of 
its parents) is removed from the component hierarchy? The timer will keep 
requesting until forever.
    How about broadcasting the AjaxLazyLoadTimer to all components, giving them 
the opportunity to keep the timer running?
    
        ((AjaxLazyLoadTimer)event.getPayload()).notReadyForReplacement();
    
    If any of the panels is not ready yet, the timer has to keep running.


> AjaxLazyLoadPanel should provide non-blocking lazy load
> -------------------------------------------------------
>
>                 Key: WICKET-6055
>                 URL: https://issues.apache.org/jira/browse/WICKET-6055
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>    Affects Versions: 7.1.0
>            Reporter: Martijn Dashorst
>            Assignee: Martijn Dashorst
>
> When having multiple AjaxLazyLoadPanels on your page, they all block their 
> Wicket request thread until the content is ready to load. This can be 
> problematic when you try to wait for some background job to finish and want 
> to poll for that job to be ready, and only then update the contents.
> The improvement would be to add a method that gives the developer the option 
> to not update just yet (isReadyForReplacement) and when it returns true, 
> start the replacement. By default this would return true, implementing the 
> current behavior of the AjaxLazyLoadPanel.
> Furthermore to improve the responsiveness of the ALLP it should add a single 
> timer to the page that can be used by multiple ALLPs to update themselves. 
> The timer would poll each second and the ALLPs would use Wicket's event bus 
> to update themselves. With some reference counting, the timer can remove 
> itself from the page when all ALLPs have updated themselves.
> This enables refreshing the page as well when outside an AJAX context, or 
> having a user be impatient and pressing F5.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to