You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Matej Knopp (JIRA)" <ji...@apache.org> on 2007/05/24 18:31:16 UTC

[jira] Resolved: (WICKET-556) Prevent setTimeout for AjaxSelfUpdatingTimerBehavior from firing after its contributing component has been replaced

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

Matej Knopp resolved WICKET-556.
--------------------------------

    Resolution: Fixed

> Prevent setTimeout for AjaxSelfUpdatingTimerBehavior from firing after its contributing component has been replaced
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-556
>                 URL: https://issues.apache.org/jira/browse/WICKET-556
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.0
>            Reporter: Jim McLaughlin
>         Assigned To: Matej Knopp
>             Fix For: 1.3.0
>
>
> Currently, the setTimeout for an AjaxTimerBehavior will fire after the contributing component has been replaced or removed through an ajax request. This will result in an exception server side and a full page refresh client side.
> One possible solution is to override getCallbackScript() to enclose the ajax callback in another function that will only execute the ajax request if the markup for the contributing component is still in the dom tree:
>             protected CharSequence getCallbackScript(boolean recordPageVersion)
>             {
>                 String mId = getComponent().getMarkupId();
>                 StringBuilder sb = new StringBuilder("exec_func(function() { ");
>                 sb.append("var el = wicketGet('" + mId + "'); ");
>                 sb.append("if(null != el) {");
>                 sb.append(super.getCallbackScript(recordPageVersion));
>                 sb.append("}");
>                 sb.append("})");
>                
>                 return sb.toString ();
>             }
> Other options are to have the request cycle swallow the "component not found" exception for timer behaviors (since they will only fire 1 extra  time)
> or
> a more complicated scheme would involve wicket actively managing javascript timer tokens client side so that they  can be removed with clearTimeout when their contributing component is removed through an ajax request. The javascript to do this would be trivial (a simple container object mapping dom id to timer token), but the wicket lifecycle would need to support an onRemove callback for components to perform cleanup.

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