java.lang.Object
org.apache.wicket.behavior.Behavior
org.apache.wicket.behavior.AbstractAjaxBehavior
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
org.apache.wicket.ajax.AbstractAjaxTimerBehavior
- All Implemented Interfaces:
Serializable
,IComponentAwareEventSink
,IRequestListener
,IComponentAwareHeaderContributor
,IClusterable
- Direct Known Subclasses:
AjaxClientInfoBehavior
,AjaxLazyLoadPanel.AjaxLazyLoadTimer
,AjaxSelfUpdatingTimerBehavior
A behavior that generates an AJAX update callback at a regular interval.
- Since:
- 1.2
- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
-
Field Summary
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
Create an identifier for the JavaScript timer.final Duration
Returns the update intervalfinal boolean
void
Called to notify that the component is being removed from its parentstatic AbstractAjaxTimerBehavior
onTimer
(Duration interval, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onTimer) Creates anAbstractAjaxTimerBehavior
based on lambda expressionsprotected 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 final void
respond
(AjaxRequestTarget target) final void
restart
(IPartialPageRequestHandler target) Restart the timer.protected final void
setUpdateInterval
(Duration updateInterval) Sets the update interval duration.protected boolean
Decides whether the timer behavior should render its JavaScript to re-trigger it after the update interval.final void
stop
(IPartialPageRequestHandler target) Stops the timer.Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onMethodMismatch, 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, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onTag
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.wicket.IRequestListener
rendersPage
-
Constructor Details
-
AbstractAjaxTimerBehavior
Construct.- Parameters:
updateInterval
-Duration
between AJAX callbacks
-
-
Method Details
-
setUpdateInterval
Sets the update interval duration. This method should only be called within theonTimer(AjaxRequestTarget)
method.- Parameters:
updateInterval
-
-
getUpdateInterval
Returns the update interval- Returns:
- The update interval
-
renderHead
Description copied from class:Behavior
Render to the web response whatever the component wants to contribute to the head section.- Specified by:
renderHead
in interfaceIComponentAwareHeaderContributor
- Overrides:
renderHead
in classAbstractDefaultAjaxBehavior
- 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 interfaceresponse
- Response object- See Also:
-
respond
- Specified by:
respond
in classAbstractDefaultAjaxBehavior
- Parameters:
target
- The AJAX target
-
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
Listener method for the AJAX timer event.- Parameters:
target
- The request target
-
isStopped
- Returns:
true
if has been stopped viastop(IPartialPageRequestHandler)
-
restart
Restart the timer.- Parameters:
target
- may be null
-
getTimerId
Create an identifier for the JavaScript timer.Note: The identifier must not change as long as this behavior is attached to a component!
- Returns:
- creates an id based on
Component.getMarkupId()
andComponent.getBehaviorById(int)
by default
-
stop
Stops the timer.- Parameters:
target
- may be null
-
onRemove
Description copied from class:Behavior
Called to notify that the component is being removed from its parent -
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 classAbstractAjaxBehavior
-
onTimer
public static AbstractAjaxTimerBehavior onTimer(Duration interval, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onTimer) Creates anAbstractAjaxTimerBehavior
based on lambda expressions- Parameters:
interval
- the interval the timeronTimer
- the consumer which accepts theAjaxRequestTarget
- Returns:
- the
AbstractAjaxTimerBehavior
-