[ 
https://issues.apache.org/jira/browse/WICKET-2152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Igor Vaynberg resolved WICKET-2152.
-----------------------------------

       Resolution: Duplicate
    Fix Version/s:     (was: 1.5-M1)

> AbstractAjaxTimerBehavior is stoppable, would be nice to have it restartable
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-2152
>                 URL: https://issues.apache.org/jira/browse/WICKET-2152
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.5, 1.4-M3, 1.5-M1
>         Environment: All
>            Reporter: Daniel Toffetti
>            Priority: Trivial
>
> My use case is: I have a page with an AjaxSelfUpdatingTimerBehavior and a 
> button that opens a modal window. If the modal window is opened and the timer 
> fires the refresh, the browser ask for a confirmation to leave the page, and 
> then closes the modal window.
> It would be very nice to be able to stop the self updating behavior just 
> before opening the modal window, and restarting it just before closing it. 
> This feature has already been requested long ago in SourceForge tracker, see: 
> http://www.nabble.com/forum/ViewPost.jtp?post=5773807&framed=y, but couldn't 
> find it in JIRA.
> To overcome this problem, I created a custom (AbstractAjax + 
> AjaxSelfUpdating)TimerBehavior, and added this method:
>       /**
>        * Starts the timer
>        */
>       public final void start(final AjaxRequestTarget target)
>       {
>               stopped = false;
>               target.getHeaderResponse().renderOnLoadJavascript(
>                                                               
> getJsTimeoutCall(updateInterval));
>       }
> And changed (this might not be important, I'm not sure but this works for me):
>       /**
>        *
>        * @see 
> org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
>        */
>       protected final void respond(final AjaxRequestTarget target)
>       {
>               onTimer(target);
>               if (!stopped) {
>                       target.getHeaderResponse().renderOnLoadJavascript(
>                                                                       
> getJsTimeoutCall(updateInterval));
>               }
>       }
> to:
>       /**
>        *
>        * @see 
> org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
>        */
>       protected final void respond(final AjaxRequestTarget target)
>       {
>               if (!stopped) {
>                       onTimer(target);
>                       target.getHeaderResponse().renderOnLoadJavascript(
>                                                                       
> getJsTimeoutCall(updateInterval));
>               }
>       }
> Then in the onClick of the button that opens the modal window, I call;
>             @Override
>             public void onClick(AjaxRequestTarget target) {
>                 autoRefreshBehavior.stop();
>                 //---
> and in the onClose of the modal window:
>                     @Override
>                     public void onClose(AjaxRequestTarget target) {
>                         //---
>                         autoRefreshBehavior.start(target);
>                     }
> It's working fine so far, but it would be nice to have this little feature or 
> something similar provided in core.

-- 
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