wicket.behavior
Class AbstractAjaxBehavior

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

public abstract class AbstractAjaxBehavior
extends AbstractBehavior
implements IBehaviorListener, IHeaderContributor

Abstract class for handling Ajax roundtrips. This class serves as a base for javascript specific implementations, like ones based on Dojo or Scriptaculous, or Wicket's default.

Author:
Eelco Hillenius, Ralf Ebert, Igor Vaynberg
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
AbstractAjaxBehavior()
          Construct.
 
Method Summary
 void bind(Component hostComponent)
          Bind this handler to the given component.
 void cleanup()
          This method is called either by AbstractBehavior.onRendered(Component) or AbstractBehavior.onException(Component, RuntimeException) AFTER they called their respective template methods.
 java.lang.CharSequence getCallbackUrl()
          Gets the url that references this handler.
 java.lang.CharSequence getCallbackUrl(boolean recordPageVersion, boolean onlyTargetActivePage)
          Gets the url that references this handler.
protected  Component getComponent()
          Gets the component that this handler is bound to.
protected abstract  java.lang.String getImplementationId()
          Deprecated. The mechanism will be changed for Wicket 2.0, where doubles are filtered in (future) class IHeaderResponse.
protected  void onBind()
          Called when the component was bound to it's host component.
protected  void onComponentRendered()
          Called to indicate that the component that has this handler registered has been rendered.
 void onComponentTag(Component component, ComponentTag tag)
          Called any time a component that has this behavior registered is rendering the component tag.
protected  void onComponentTag(ComponentTag tag)
          Called any time a component that has this handler registered is rendering the component tag.
 void onRendered(Component hostComponent)
          Called when a component that has this behavior coupled was rendered.
protected  void onRenderHeadContribution(Response response)
          Let this handler print out the needed header contributions.
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 renderHead(Response response)
          Render to the web response whatever the component wants to contribute to the head section.
protected  void writeJsReference(Response response, PackageResourceReference ref)
          Deprecated. use writeJsReference(Response, ResourceReference) instead
protected  void writeJsReference(Response response, ResourceReference ref)
          Convenience method to add a javascript reference.
 
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
 
Methods inherited from interface wicket.behavior.IBehaviorListener
onRequest
 

Constructor Detail

AbstractAjaxBehavior

public AbstractAjaxBehavior()
Construct.

Method Detail

bind

public final void bind(Component hostComponent)
Bind this handler to the given component.

Specified by:
bind in interface IBehavior
Overrides:
bind in class AbstractBehavior
Parameters:
hostComponent - the component to bind to
See Also:
IBehavior.bind(wicket.Component)

getCallbackUrl

public java.lang.CharSequence getCallbackUrl()
Gets the url that references this handler.

Returns:
the url that references this handler

getCallbackUrl

public final java.lang.CharSequence getCallbackUrl(boolean recordPageVersion,
                                                   boolean onlyTargetActivePage)
Gets the url that references this handler.

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:
the url that references this handler

onComponentTag

public final void onComponentTag(Component component,
                                 ComponentTag tag)
Description copied from interface: IBehavior
Called any time a component that has this behavior registered is rendering the component tag.

Specified by:
onComponentTag in interface IBehavior
Overrides:
onComponentTag in class AbstractBehavior
Parameters:
component - the component that renders this tag currently
tag - the tag that is rendered
See Also:
IBehavior.onComponentTag(wicket.Component, wicket.markup.ComponentTag)

onRendered

public final void onRendered(Component hostComponent)
Description copied from class: AbstractBehavior
Called when a component that has this behavior coupled was rendered.

Overrides:
onRendered in class AbstractBehavior
Parameters:
hostComponent - the component that has this behavior coupled
See Also:
AbstractBehavior.onRendered(wicket.Component)

cleanup

public void cleanup()
Description copied from class: AbstractBehavior
This method is called either by AbstractBehavior.onRendered(Component) or AbstractBehavior.onException(Component, RuntimeException) AFTER they called their respective template methods. Override this template method to do any necessary cleanup.

Overrides:
cleanup in class AbstractBehavior
See Also:
AbstractBehavior.cleanup()

renderHead

public final void renderHead(Response response)
Description copied from interface: IHeaderContributor
Render to the web response whatever the component wants to contribute to the head section.

Note: This method is kind of dangerous as users are able to write to the output whatever they like.

Specified by:
renderHead in interface IHeaderContributor
Parameters:
response - Response object
See Also:
IHeaderContributor.renderHead(wicket.Response)

writeJsReference

protected void writeJsReference(Response response,
                                PackageResourceReference ref)
Deprecated. use writeJsReference(Response, ResourceReference) instead

Convenience method to add a javascript reference.

Parameters:
response -
ref - reference to add

writeJsReference

protected void writeJsReference(Response response,
                                ResourceReference ref)
Convenience method to add a javascript reference.

Parameters:
response -
ref - reference to add

getComponent

protected final Component getComponent()
Gets the component that this handler is bound to.

Returns:
the component that this handler is bound to

getImplementationId

protected abstract java.lang.String getImplementationId()
Deprecated. The mechanism will be changed for Wicket 2.0, where doubles are filtered in (future) class IHeaderResponse.

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.

Returns:
unique id of an ajax implementation

onComponentTag

protected void onComponentTag(ComponentTag tag)
Called any time a component that has this handler registered is rendering the component tag. Use this method e.g. to bind to javascript event handlers of the tag

Parameters:
tag - the tag that is rendered

onBind

protected void onBind()
Called when the component was bound to it's host component. You can get the bound host component by calling getComponent.


onComponentRendered

protected void onComponentRendered()
Called to indicate that the component that has this handler registered has been rendered. Use this method to do any cleaning up of temporary state


onRenderHeadContribution

protected void onRenderHeadContribution(Response response)
Let this handler print out the needed header contributions. This implementation does nothing.

Parameters:
response - head container

onRenderHeadInitContribution

protected void onRenderHeadInitContribution(Response response)
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.

Parameters:
response - head container


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