org.wicketstuff.push.timer
Class TimerChannelBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      extended by org.apache.wicket.behavior.AbstractAjaxBehavior
          extended by org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
              extended by org.apache.wicket.ajax.AbstractAjaxTimerBehavior
                  extended by org.wicketstuff.push.timer.TimerChannelBehavior
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.behavior.IBehavior, org.apache.wicket.behavior.IBehaviorListener, org.apache.wicket.IClusterable, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IHeaderContributor

public class TimerChannelBehavior
extends org.apache.wicket.ajax.AbstractAjaxTimerBehavior
implements java.io.Serializable

Behavior used to enqueue triggers and send them to the client using timer based polling.

The polling interval is configured in the constructor. The more frequent is the polling, the more quickly your client will be updated, but also the more you will load your server and your network.

A timeout can also be configured to indicate when the behavior should consider the page has been disconnected. This is important to clean appropriately the resources associated with the page.

Author:
Xavier Hanin
See Also:
IChannelService, TimerChannelService, TimerPushService, Serialized Form

Nested Class Summary
static class TimerChannelBehavior.TimerPushTarget
          An IPushTarget implementation which enqueue DelayedMethodCallList, also called triggers, for a TimerChannelBehavior identified by its id.
 
Field Summary
 
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
 
Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
TimerChannelBehavior(org.apache.wicket.util.time.Duration updateInterval)
          Construct a TimerChannelBehavior which actually refreshes the clients by polling the server for changes at the given duration.
TimerChannelBehavior(org.apache.wicket.util.time.Duration updateInterval, org.apache.wicket.util.time.Duration timeout)
          Construct a TimerChannelBehavior which actually refreshes the clients by polling the server for changes at the given duration.
 
Method Summary
 java.lang.String getId()
           
static boolean isConnected(org.apache.wicket.Application application, java.lang.String id, org.apache.wicket.util.time.Duration timeout)
           
 IPushTarget newPushTarget()
          Creates a new push target to which triggers can be sent
protected  void onBind()
           
protected  void onTimer(org.apache.wicket.ajax.AjaxRequestTarget target)
           
 void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.wicket.ajax.AbstractAjaxTimerBehavior
getCallbackScript, getJsTimeoutCall, getPreconditionScript, getUpdateInterval, isStopped, onlyTargetActivePage, respond, setUpdateInterval, stop
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, generateCallbackScript, getAjaxCallDecorator, getCallbackScript, getChannelName, getFailureScript, getSuccessScript, onRequest, throttleScript
 
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
bind, getCallbackUrl, getCallbackUrl, getComponent, getImplementationId, getStatelessHint, onComponentRendered, onComponentTag, onComponentTag, onRendered, onRenderHeadContribution, onRenderHeadInitContribution
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, cleanup, detach, detachModel, exception, isEnabled, isTemporary, onException, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimerChannelBehavior

public TimerChannelBehavior(org.apache.wicket.util.time.Duration updateInterval)
Construct a TimerChannelBehavior which actually refreshes the clients by polling the server for changes at the given duration.

Parameters:
updateInterval - the interval at which the server should be polled for changes

TimerChannelBehavior

public TimerChannelBehavior(org.apache.wicket.util.time.Duration updateInterval,
                            org.apache.wicket.util.time.Duration timeout)
Construct a TimerChannelBehavior which actually refreshes the clients by polling the server for changes at the given duration.

Parameters:
updateInterval - the interval at which the server should be polled for changes
Method Detail

onBind

protected void onBind()
Overrides:
onBind in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior

onTimer

protected void onTimer(org.apache.wicket.ajax.AjaxRequestTarget target)
Specified by:
onTimer in class org.apache.wicket.ajax.AbstractAjaxTimerBehavior
See Also:
AbstractAjaxTimerBehavior.onTimer(AjaxRequestTarget)

newPushTarget

public IPushTarget newPushTarget()
Creates a new push target to which triggers can be sent

Returns:
an IPushTarget to which triggers can be sent in any thread.

renderHead

public void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
Specified by:
renderHead in interface org.apache.wicket.markup.html.IHeaderContributor
Overrides:
renderHead in class org.apache.wicket.ajax.AbstractAjaxTimerBehavior

isConnected

public static boolean isConnected(org.apache.wicket.Application application,
                                  java.lang.String id,
                                  org.apache.wicket.util.time.Duration timeout)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getId

public java.lang.String getId()


Copyright © 2010. All Rights Reserved.