wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: AjaxSelfUpdatingTimerBehavior does not stop itself properly after certain time
Date Mon, 30 Sep 2013 12:23:57 GMT
Hi,

Put a breakpoint in #onPostProcessTarget() and make sure that stop(target)
is invoked.
Then check the Ajax response for this request and verify that it has
something like:
  delete Wicket.TimerHandles['instance103']
and that there is no another setTimeout() call in the <evaluation> elements
in the response.

As last resort create a quickstart app and attach it to a ticket so we can
debug it and fix it if there is a problem.


On Mon, Sep 30, 2013 at 2:12 PM, Behrooz Nobakht <nobeh5@gmail.com> wrote:

> Hello,
>
> I have a custom AjaxSelfUpdatingTimerBehavior as follows:
>
> public class LimitedAjaxSelfUpdatingTimerBehavior extends
> AjaxSelfUpdatingTimerBehavior {
>     private static final long serialVersionUID = 1L;
>
>     public static final long MAX_IDLE_TIME =
> TimeUnit.SECONDS.toMillis(120);
>
>     private final Logger logger = LoggerFactory.getLogger(getClass());
>
>     private final AtomicLong createdTime = new
> AtomicLong(System.currentTimeMillis());
>
>     private final AtomicBoolean expired = new AtomicBoolean(false);
>
>     public LimitedAjaxSelfUpdatingTimerBehavior() {
>         this(Duration.milliseconds(MAX_IDLE_TIME));
>     }
>
>     protected LimitedAjaxSelfUpdatingTimerBehavior(Duration
> updateInterval) {
>         super(updateInterval);
>     }
>
>     @Override
>     protected final void onPostProcessTarget(AjaxRequestTarget target) {
>         if (expired.get()) {
>             stop(target);
>             return;
>         }
>         doProcessTarget(target);
>     }
>
>     @Override
>     protected boolean shouldTrigger() {
>         long idle = System.currentTimeMillis() - createdTime.get();
>         expired.compareAndSet(false, idle > MAX_IDLE_TIME);
>         if (expired.get()) {
>             logger.warn("A message");
>
>             // find the AJAX request and stop it
>             AjaxRequestTarget target =
> RequestCycle.get().find(AjaxRequestTarget.class);
>             stop(target);
>         }
>         return !expired.get();
>     }
>
>     /**
>      * @param target
>      */
>     protected void doProcessTarget(AjaxRequestTarget target) {
>     }
> }
>
> I use this behavior on a set of my components in a Wicket page, however,
> after the default timeout passes, I can still see in the browser debug
> console XHR requests such as:
>
>
> http://localhost:8081/w/wicket/page?1-1.IBehaviorListener.0-serviceInstances-0-serviceInstanceServerInstances-content-servers-0-server-instances-0-instance&_=1380542862344
>
> And the response to such XHR looks like:
>
> <ajax-response>
> <evaluate encoding="wicket1">
> <![CDATA[
> (function(){Wicket.TimerHandles['instance103']^ =
>
> setTimeout('Wicket.Ajax.ajax({\"u\":\"./page?1-1.IBehaviorListener.0-serviceInstances-0-serviceInstanceServerInstances-content-servers-0-server-instances-0-instance\",\"c\":\"instance103\"});',
> 10000)})();
> ]]>
>
> </evaluate>
>
> </ajax-response>
>
> which shows that the behavior has *not* been stopped for the component.
>
> What am I missing or doing in a wrong way?
>
> Thanks for the help!— Behrooz Nobakht
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message