org.apache.wicket.ajax
Class AbstractAjaxTimerBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.behavior.AbstractAjaxBehavior
          extended by org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
              extended by org.apache.wicket.ajax.AbstractAjaxTimerBehavior
All Implemented Interfaces:
Serializable, IBehaviorListener, IComponentAwareEventSink, IRequestListener, IComponentAwareHeaderContributor, IClusterable
Direct Known Subclasses:
AjaxClientInfoBehavior, AjaxSelfUpdatingTimerBehavior

public abstract class AbstractAjaxTimerBehavior
extends AbstractDefaultAjaxBehavior

A behavior that generates an AJAX update callback at a regular interval.

Since:
1.2
Author:
Igor Vaynberg (ivaynberg)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
 
Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
AbstractAjaxTimerBehavior(Duration updateInterval)
          Construct.
 
Method Summary
protected  String getJsTimeoutCall(Duration updateInterval)
           
 Duration getUpdateInterval()
          Returns the update interval
 boolean isStopped()
           
 void onRemove(Component component)
          Called to notify that the component is being removed from its parent
protected  void onRestart(AjaxRequestTarget target)
          Called when this timer is restarted adds this component to the target on restart.
protected abstract  void onTimer(AjaxRequestTarget target)
          Listener method for the AJAX timer event.
protected  void onUnbind()
          Called when the behavior is removed from its component.
 void renderHead(Component component, IHeaderResponse response)
          Render to the web response whatever the component wants to contribute to the head section.
protected  void respond(AjaxRequestTarget target)
           
 void restart(AjaxRequestTarget target)
          Re-enables the timer if already stopped
protected  void setUpdateInterval(Duration updateInterval)
          Sets the update interval duration.
protected  boolean shouldTrigger()
          Decides whether the timer behavior should render its JavaScript to re-trigger it after the update interval.
 void stop(AjaxRequestTarget target)
          Stops the timer.
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, getChannel, getFailureScript, getPreconditionScript, getSuccessScript, onBind, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes, updateAjaxAttributes
 
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, unbind
 
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onConfigure, onEvent, onException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAjaxTimerBehavior

public AbstractAjaxTimerBehavior(Duration updateInterval)
Construct.

Parameters:
updateInterval - Duration between AJAX callbacks
Method Detail

setUpdateInterval

protected final void setUpdateInterval(Duration updateInterval)
Sets the update interval duration. This method should only be called within the onTimer(AjaxRequestTarget) method.

Parameters:
updateInterval -

getUpdateInterval

public final Duration getUpdateInterval()
Returns the update interval

Returns:
The update interval

renderHead

public void renderHead(Component component,
                       IHeaderResponse response)
Description copied from class: Behavior
Render to the web response whatever the component wants to contribute to the head section.

Specified by:
renderHead in interface IComponentAwareHeaderContributor
Overrides:
renderHead in class AbstractDefaultAjaxBehavior
Parameters:
component - component which is contributing to the response. This parameter is here to give the component as the context for component-awares implementing this interface
response - Response object
See Also:
Behavior.renderHead(Component, org.apache.wicket.markup.head.IHeaderResponse)

getJsTimeoutCall

protected final String getJsTimeoutCall(Duration updateInterval)
Parameters:
updateInterval - Duration between AJAX callbacks
Returns:
JS script

respond

protected final void respond(AjaxRequestTarget target)
Specified by:
respond in class AbstractDefaultAjaxBehavior
Parameters:
target - The AJAX target
See Also:
AbstractDefaultAjaxBehavior.respond(AjaxRequestTarget)

shouldTrigger

protected boolean shouldTrigger()
Decides whether the timer behavior should render its JavaScript to re-trigger it after the update interval.

Returns:
true if the behavior is not stopped, it is enabled and still attached to any component in the page or to the page itself

onTimer

protected abstract void onTimer(AjaxRequestTarget target)
Listener method for the AJAX timer event.

Parameters:
target - The request target

isStopped

public final boolean isStopped()
Returns:
true if has been stopped via stop(AjaxRequestTarget)

restart

public final void restart(AjaxRequestTarget target)
Re-enables the timer if already stopped

Parameters:
target - may be null

onRestart

protected void onRestart(AjaxRequestTarget target)
Called when this timer is restarted adds this component to the target on restart.
Note: This method will be removed in Wicket 7.x, thus the hosting component will no longer be updated on each restart.

Parameters:
target - current target

stop

public final void stop(AjaxRequestTarget target)
Stops the timer.

Parameters:
target - may be null

onRemove

public void onRemove(Component component)
Description copied from class: Behavior
Called to notify that the component is being removed from its parent

Overrides:
onRemove in class Behavior
Parameters:
component - the removed component

onUnbind

protected void onUnbind()
Description copied from class: AbstractAjaxBehavior
Called when the behavior is removed from its component. The bound host component is still available through AbstractAjaxBehavior.getComponent(). The relation to it will be removed right after the finish of the execution of this method.

Overrides:
onUnbind in class AbstractAjaxBehavior


Copyright © 2006–2014 Apache Software Foundation. All rights reserved.