Wicket
  1. Wicket
  2. WICKET-2152

AbstractAjaxTimerBehavior is stoppable, would be nice to have it restartable

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Duplicate
    • Affects Version/s: 1.3.5, 1.4-M3, 1.5-M1
    • Fix Version/s: None
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      All

      Description

      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.

        Issue Links

          Activity

          Daniel Toffetti created issue -
          Hide
          Daniel Toffetti added a comment -

          Oops, this seems to be a dupe of:
          https://issues.apache.org/jira/browse/WICKET-1525
          Sorry.

          Show
          Daniel Toffetti added a comment - Oops, this seems to be a dupe of: https://issues.apache.org/jira/browse/WICKET-1525 Sorry.
          Igor Vaynberg made changes -
          Field Original Value New Value
          Link This issue duplicates WICKET-1525 [ WICKET-1525 ]
          Igor Vaynberg made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.5-M1 [ 12313078 ]
          Resolution Duplicate [ 3 ]
          Hide
          Martin Grigorov added a comment -

          I attached a patch to WICKET-1525.
          Daniel, please take a look and share your opinion.
          Saludos!

          Show
          Martin Grigorov added a comment - I attached a patch to WICKET-1525 . Daniel, please take a look and share your opinion. Saludos!
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          1d 15h 59m 1 Igor Vaynberg 10/Mar/09 17:51

            People

            • Assignee:
              Unassigned
              Reporter:
              Daniel Toffetti
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development