public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler, final Duration pollingInterval) { TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior == null) { behavior = new TimerPushBehavior(pollingInterval); component.add(behavior); } final TimerPushNode<EventType> node = behavior.addNode(handler, pollingInterval); _onConnect(node); return node; }
@Override public void renderHead(final IHeaderResponse response) { super.renderHead(response); if (!isStopped()) { // install an onunload handler response.renderJavascript("history.navigationMode = 'compatible';", "Opera onunload support"); response.renderOnEventJavascript("window", "unload", "wicketAjaxGet('" + getCallbackUrl().toString() + "&unload=1', function() { }, function() { });"); } } }
<EventType> TimerPushNode<EventType> addNode( final IPushEventHandler<EventType> pushEventHandler, final Duration pollingInterval) { if (pollingInterval.lessThan(getUpdateInterval())) setUpdateInterval(pollingInterval); final TimerPushNode<EventType> node = new TimerPushNode<EventType>(pollingInterval); handlers.put(node, pushEventHandler); return node; }
public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler, final Duration pollingInterval) { Args.notNull(component, "component"); Args.notNull(handler, "handler"); Args.notNull(pollingInterval, "pollingInterval"); TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior != null && behavior.isStopped()) { component.remove(behavior); behavior = null; } if (behavior == null) { behavior = new TimerPushBehavior(pollingInterval); component.add(behavior); } final TimerPushNode<EventType> node = behavior.addNode(handler, pollingInterval); _onConnect(node); return node; }
/** * {@inheritDoc} */ public void uninstallNode(final Component component, final IPushNode<?> node) { Args.notNull(component, "component"); Args.notNull(node, "node"); if (node instanceof TimerPushNode) { final TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior == null) return; if (behavior.removeNode(node) == 0) behavior.stop(RequestCycle.get().find(AjaxRequestTarget.class).get()); } else LOG.warn("Unsupported push node type {}", node); } }
protected void onTimer(final AjaxRequestTarget target) if (isStopped()) getComponent().remove(this); return;
int removeNode(final IPushNode<?> node) { handlers.remove(node); // adjust the polling interval based on the fastest remaining node Duration newPollingInterval = Duration.MAXIMUM; for (final TimerPushNode n : handlers.keySet()) if (n.getPollingInterval().lessThan(newPollingInterval)) newPollingInterval = n.getPollingInterval(); setUpdateInterval(newPollingInterval); return handlers.size(); }
/** * {@inheritDoc} */ public void uninstallNode(final Component component, final IPushNode<?> node) { if (node instanceof TimerPushNode) { final TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior == null) return; if (behavior.removeNode(node) == 0) component.remove(behavior); } else LOG.warn("Unsupported push node type {}", node); } }
/** * @return the number of handlers after the removal */ int removeNode(final IPushNode<?> node) { handlers.remove(node); // adjust the polling interval based on the fastest remaining node Duration newPollingInterval = Duration.MAXIMUM; for (final TimerPushNode n : handlers.keySet()) if (n.getPollingInterval().lessThan(newPollingInterval)) newPollingInterval = n.getPollingInterval(); setUpdateInterval(newPollingInterval); return handlers.size(); }
<EventType> TimerPushNode<EventType> addNode( final IPushEventHandler<EventType> pushEventHandler, final Duration pollingInterval) { if (pollingInterval.lessThan(getUpdateInterval())) setUpdateInterval(pollingInterval); final TimerPushNode<EventType> node = new TimerPushNode<EventType>(pollingInterval); handlers.put(node, pushEventHandler); return node; }
/** * {@inheritDoc} */ @Override public void renderHead(final Component c, final IHeaderResponse response) { super.renderHead(c, response); if (!isStopped()) { // install an on-unload handler response.render(JavaScriptHeaderItem.forScript("history.navigationMode = 'compatible';", "Opera on-unload support")); response.render(OnEventHeaderItem.forScript("window", "unload", "Wicket.Ajax.get({'u': '" + getCallbackUrl().toString() + "&unload=1'});")); } } }