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:
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 abstract  void onTimer(AjaxRequestTarget target)
          Listener method for the AJAX timer event.
 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, onUnbind, 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 -

stop

public final void stop(AjaxRequestTarget target)
Stops the timer


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


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.