/** * Set the timeout on the given {@link IHeaderResponse}. Implementation note: * <p> * {@link #respond(AjaxRequestTarget)} might set the timer once and * {@link #renderHead(Component, IHeaderResponse)} a second time successively, if the attached * component is re-rendered on the same {@link AjaxRequestTarget}. * <p> * But rendering of the component might <em>not</em> actually happen on the same {@link AjaxRequestTarget}, * e.g. when a redirect to a full page-render is scheduled. Thus this method <em>always</em> sets the timeout * and in the former case {@link AjaxRequestTarget} will take care of executing one of the * two {@link OnLoadHeaderItem}s only. * * @param headerResponse */ private void setTimeout(IHeaderResponse headerResponse) { CharSequence js = getCallbackScript(); // remember id to be able to clear it later timerId = getTimerId(); headerResponse.render( OnLoadHeaderItem.forScript(String.format("Wicket.Timer.set('%s', function(){%s}, %d);", timerId, js, updateInterval.getMilliseconds()))); }
/** * Set the timeout on the given {@link IHeaderResponse}. Implementation note: * <p> * {@link #respond(AjaxRequestTarget)} might set the timer once and * {@link #renderHead(Component, IHeaderResponse)} a second time successively, if the attached * component is re-rendered on the same {@link AjaxRequestTarget}. * <p> * But rendering of the component might <em>not</em> actually happen on the same {@link AjaxRequestTarget}, * e.g. when a redirect to a full page-render is scheduled. Thus this method <em>always</em> sets the timeout * and in the former case {@link AjaxRequestTarget} will take care of executing one of the * two {@link OnLoadHeaderItem}s only. * * @param headerResponse */ private void setTimeout(IHeaderResponse headerResponse) { CharSequence js = getCallbackScript(); // remember id to be able to clear it later timerId = getTimerId(); headerResponse.render( OnLoadHeaderItem.forScript(String.format("Wicket.Timer.set('%s', function(){%s}, %d);", timerId, js, updateInterval.getMilliseconds()))); }