wicket.ajax
Class AbstractDefaultAjaxBehavior

java.lang.Object
  extended by wicket.behavior.AbstractBehavior
      extended by wicket.behavior.AbstractAjaxBehavior
          extended by wicket.ajax.AbstractDefaultAjaxBehavior
All Implemented Interfaces:
java.io.Serializable, IBehavior, IBehaviorListener, IRequestListener, IHeaderContributor
Direct Known Subclasses:
AbstractAjaxTimerBehavior, AjaxEventBehavior

public abstract class AbstractDefaultAjaxBehavior
extends AbstractAjaxBehavior

The base class for Wicket's default AJAX implementation.

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

Field Summary
static ResourceReference INDICATOR
          reference to the default indicator gif file.
 
Fields inherited from interface wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
AbstractDefaultAjaxBehavior()
           
 
Method Summary
protected  IAjaxCallDecorator getAjaxCallDecorator()
           
protected  java.lang.CharSequence getCallbackScript()
           
protected  java.lang.CharSequence getCallbackScript(boolean recordPageVersion, boolean onlyTargetActivePage)
           
protected  java.lang.CharSequence getCallbackScript(java.lang.CharSequence partialCall, java.lang.CharSequence onSuccessScript, java.lang.CharSequence onFailureScript)
          Returns javascript that performs an ajax callback to this behavior.
protected  java.lang.String getImplementationId()
          Gets the unique id of an ajax implementation.
protected  void onBind()
          Subclasses should call super.onBind()
protected  void onRenderHeadInitContribution(Response response)
          Do a one time (per page) header contribution that is the same for all ajax variant implementations (e.g.
 void onRequest()
          Called when a request to a behavior is received.
protected abstract  void respond(AjaxRequestTarget target)
           
static java.lang.CharSequence throttleScript(java.lang.CharSequence script, java.lang.String throttleId, Duration throttleDelay)
          Wraps the provided javascript with a throttled block.
 
Methods inherited from class wicket.behavior.AbstractAjaxBehavior
bind, cleanup, getCallbackUrl, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onRendered, onRenderHeadContribution, renderHead, writeJsReference, writeJsReference
 
Methods inherited from class wicket.behavior.AbstractBehavior
detachModel, exception, onException, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDICATOR

public static final ResourceReference INDICATOR
reference to the default indicator gif file.

Constructor Detail

AbstractDefaultAjaxBehavior

public AbstractDefaultAjaxBehavior()
Method Detail

getImplementationId

protected java.lang.String getImplementationId()
Description copied from class: AbstractAjaxBehavior
Gets the unique id of an ajax implementation. This should be implemented by base classes only - like the dojo or scriptaculous implementation - to provide a means to differentiate between implementations while not going to the level of concrete implementations. It is used to ensure 'static' header contributions are done only once per implementation.

Specified by:
getImplementationId in class AbstractAjaxBehavior
Returns:
unique id of an ajax implementation
See Also:
AbstractAjaxBehavior.getImplementationId()

onBind

protected void onBind()
Subclasses should call super.onBind()

Overrides:
onBind in class AbstractAjaxBehavior
See Also:
AbstractAjaxBehavior.onBind()

onRenderHeadInitContribution

protected void onRenderHeadInitContribution(Response response)
Description copied from class: AbstractAjaxBehavior
Do a one time (per page) header contribution that is the same for all ajax variant implementations (e.g. Dojo, Scriptaculous). This implementation does nothing.

Overrides:
onRenderHeadInitContribution in class AbstractAjaxBehavior
Parameters:
response - head container
See Also:
AbstractAjaxBehavior.onRenderHeadInitContribution(wicket.Response)

getAjaxCallDecorator

protected IAjaxCallDecorator getAjaxCallDecorator()
Returns:
ajax call decorator used to decorate the call generated by this behavior or null for none

getCallbackScript

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

getCallbackScript

protected java.lang.CharSequence getCallbackScript(boolean recordPageVersion,
                                                   boolean onlyTargetActivePage)
Parameters:
recordPageVersion - if true the url will be encoded to execute on the current page version, otherwise url will be encoded to execute on the latest page version
onlyTargetActivePage - if true the callback to this behavior will be ignore if the page is not the last one the user accessed
Returns:
javascript that will generate an ajax GET request to this behavior *

getCallbackScript

protected java.lang.CharSequence getCallbackScript(java.lang.CharSequence partialCall,
                                                   java.lang.CharSequence onSuccessScript,
                                                   java.lang.CharSequence onFailureScript)
Returns javascript that performs an ajax callback to this behavior. The script is decorated by the ajax callback decorator from getAjaxCallDecorator().

Parameters:
partialCall - Javascript of a partial call to the function performing the actual ajax callback. Must be in format function(params, with signature function(params, onSuccessHandler, onFailureHandler. Example: wicketAjaxGet('callbackurl'
onSuccessScript - javascript that will run when the ajax call finishes successfully
onFailureScript - javascript that will run when the ajax call finishes with an error status
Returns:
script that peforms ajax callback to this behavior

onRequest

public final void onRequest()
Description copied from interface: IBehaviorListener
Called when a request to a behavior is received.

See Also:
IBehaviorListener.onRequest()

respond

protected abstract void respond(AjaxRequestTarget target)
Parameters:
target - The AJAX target

throttleScript

public static final java.lang.CharSequence throttleScript(java.lang.CharSequence script,
                                                          java.lang.String throttleId,
                                                          Duration throttleDelay)
Wraps the provided javascript with a throttled block. Throttled behaviors only execute once within the given delay even though they are triggered multiple times.

For example, this is useful when attaching an event behavior to the onkeypress event. It is not desirable to have an ajax call made every time the user types so we throttle that call to a desirable delay, such as once per second. This gives us a near real time ability to provide feedback without overloading the server with ajax calls.

Parameters:
script - javascript to be throttled
throttleId - the id of the throttle to be used. Usually this should remain constant for the same javascript block.
throttleDelay - time span within which the javascript block will only execute once
Returns:
wrapped javascript


Copyright © 2004-2008 Wicket developers. All Rights Reserved.