org.apache.wicket.ajax
Class AbstractAjaxTimerBehavior

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
All Implemented Interfaces:
java.io.Serializable, IBehavior, IBehaviorListener, IClusterable, IRequestListener, IHeaderContributor
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  java.lang.CharSequence getCallbackScript()
           
protected  java.lang.String getJsTimeoutCall(Duration updateInterval)
           
protected  java.lang.CharSequence getPreconditionScript()
           
 Duration getUpdateInterval()
          Returns the update interval
protected  boolean onlyTargetActivePage()
           
protected abstract  void onTimer(AjaxRequestTarget target)
          Listener method for the AJAX timer event.
 void renderHead(IHeaderResponse response)
          Render to the web response whatever the component wants to contribute to the head section.
protected  void respond(AjaxRequestTarget target)
           
protected  void setUpdateInterval(Duration updateInterval)
          Sets the update interval duration.
 void stop()
          Stops the timer
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, generateCallbackScript, getAjaxCallDecorator, getCallbackScript, getChannelName, getFailureScript, getSuccessScript, onBind, 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, toString, wait, wait, wait
 

Constructor Detail

AbstractAjaxTimerBehavior

public AbstractAjaxTimerBehavior(Duration updateInterval)
Construct.

Parameters:
updateInterval - Duration between AJAX callbacks
Method Detail

stop

public final void stop()
Stops the timer


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(IHeaderResponse response)
Description copied from interface: IHeaderContributor
Render to the web response whatever the component wants to contribute to the head section. TODO: Post 1.3, add component parameter, so that the behaviors dont' have to track component instances

Specified by:
renderHead in interface IHeaderContributor
Overrides:
renderHead in class AbstractDefaultAjaxBehavior
Parameters:
response - Response object
See Also:
AbstractAjaxBehavior.renderHead(org.apache.wicket.markup.html.IHeaderResponse)

getJsTimeoutCall

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

getCallbackScript

protected java.lang.CharSequence getCallbackScript()
Overrides:
getCallbackScript in class AbstractDefaultAjaxBehavior
Returns:
javascript that will generate an ajax GET request to this behavior

getPreconditionScript

protected java.lang.CharSequence getPreconditionScript()
Overrides:
getPreconditionScript in class AbstractDefaultAjaxBehavior
Returns:
an optional javascript expression that determines whether the request will actually execute (in form of return XXX;);
See Also:
AbstractDefaultAjaxBehavior.getPreconditionScript()

onlyTargetActivePage

protected boolean onlyTargetActivePage()

respond

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

onTimer

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

Parameters:
target - The request target


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.