org.apache.wicket.behavior
Class AbstractBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
All Implemented Interfaces:
java.io.Serializable, IBehavior, IClusterable, IHeaderContributor
Direct Known Subclasses:
AbstractAjaxBehavior, AbstractHeaderContributor, AbstractTransformerBehavior, AttributeModifier, ContainerWithAssociatedMarkupHelper, DatePicker, SimpleAttributeModifier, VelocityContributor, WicketAjaxIndicatorAppender, WicketMessageTagHandler.AttributeLocalizer

public abstract class AbstractBehavior
extends java.lang.Object
implements IBehavior, IHeaderContributor

Adapter implementation of IBehavior. It is recommended to extend from this class instead of directly implementing IBehavior as this class has an extra clean

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

Constructor Summary
AbstractBehavior()
          Construct.
 
Method Summary
 void afterRender(Component component)
          Called when a component that has this behavior coupled was rendered.
 void beforeRender(Component component)
          Called when a component is about to render.
 void bind(Component component)
          Bind this handler to the given component.
 void cleanup()
          This method is called either by onRendered(Component) or onException(Component, RuntimeException) AFTER they called their respective template methods.
 void detach(Component component)
          Allows the behavior to detach any state it has attached during request processing.
 void detachModel(Component component)
          Deprecated. replaced by detach(Component)
 void exception(Component component, java.lang.RuntimeException exception)
          In case an unexpected exception happened anywhere between onComponentTag() and rendered(), onException() will be called for any behavior.
 boolean getStatelessHint(Component component)
          This method returns false if the behavior generates a callback url (for example ajax behaviors)
 boolean isEnabled(Component component)
          Called when a components is rendering and wants to render this behavior.
 boolean isTemporary()
          Specifies whether or not this behavior is temporary.
 void onComponentTag(Component component, ComponentTag tag)
          Called any time a component that has this behavior registered is rendering the component tag.
 void onException(Component component, java.lang.RuntimeException exception)
          In case an unexpected exception happened anywhere between onComponentTag() and rendered(), onException() will be called for any behavior.
 void onRendered(Component component)
          Called when a component that has this behavior coupled was rendered.
 void rendered(Component component)
          Deprecated. replaced by afterRender(Component)
 void renderHead(IHeaderResponse response)
          Render to the web response whatever the component wants to contribute to the head section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBehavior

public AbstractBehavior()
Construct.

Method Detail

beforeRender

public void beforeRender(Component component)
Description copied from interface: IBehavior
Called when a component is about to render.

Specified by:
beforeRender in interface IBehavior
Parameters:
component - the component that has this behavior coupled
See Also:
IBehavior.beforeRender(org.apache.wicket.Component)

bind

public void bind(Component component)
Description copied from interface: IBehavior
Bind this handler to the given component. This method is called by the host component immediately after this behavior is added to it. This method is useful if you need to do initialization based on the component it is attached and you can't wait to do it at render time. Keep in mind that if you decide to keep a reference to the host component, it is not thread safe anymore, and should thus only be used in situations where you do not reuse the behavior for multiple components.

Specified by:
bind in interface IBehavior
Parameters:
component - the component to bind to
See Also:
IBehavior.bind(org.apache.wicket.Component)

cleanup

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


detach

public void detach(Component component)
Description copied from interface: IBehavior
Allows the behavior to detach any state it has attached during request processing.

Specified by:
detach in interface IBehavior
Parameters:
component - the component that initiates the detachment of this behavior
See Also:
IBehavior.detach(Component)

exception

public final void exception(Component component,
                            java.lang.RuntimeException exception)
Description copied from interface: IBehavior
In case an unexpected exception happened anywhere between onComponentTag() and rendered(), onException() will be called for any behavior. Typically, if you clean up resources in IBehavior.afterRender(Component), you should do the same in the implementation of this method.

Specified by:
exception in interface IBehavior
Parameters:
component - the component that has a reference to this behavior and during which processing the exception occurred
exception - the unexpected exception
See Also:
IBehavior.exception(org.apache.wicket.Component, java.lang.RuntimeException)

getStatelessHint

public boolean getStatelessHint(Component component)
Description copied from interface: IBehavior
This method returns false if the behavior generates a callback url (for example ajax behaviors)

Specified by:
getStatelessHint in interface IBehavior
Parameters:
component - the component that has this behavior coupled.
Returns:
boolean true or false.
See Also:
IBehavior.getStatelessHint(org.apache.wicket.Component)

onComponentTag

public 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
Parameters:
component - the component that renders this tag currently
tag - the tag that is rendered
See Also:
IBehavior.onComponentTag(org.apache.wicket.Component, org.apache.wicket.markup.ComponentTag)

onException

public void onException(Component component,
                        java.lang.RuntimeException exception)
In case an unexpected exception happened anywhere between onComponentTag() and rendered(), onException() will be called for any behavior.

Parameters:
component - the component that has a reference to this behavior and during which processing the exception occurred
exception - the unexpected exception

onRendered

public void onRendered(Component component)
Called when a component that has this behavior coupled was rendered.

Parameters:
component - the component that has this behavior coupled

afterRender

public final void afterRender(Component component)
Description copied from interface: IBehavior
Called when a component that has this behavior coupled was rendered.

Specified by:
afterRender in interface IBehavior
Parameters:
component - the component that has this behavior coupled
See Also:
IBehavior.afterRender(org.apache.wicket.Component)

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
Parameters:
response - Response object
See Also:
IHeaderContributor.renderHead(org.apache.wicket.markup.html.IHeaderResponse)

isEnabled

public boolean isEnabled(Component component)
Description copied from interface: IBehavior
Called when a components is rendering and wants to render this behavior. If false is returned this behavior will be ignored.

Specified by:
isEnabled in interface IBehavior
Parameters:
component - the component that has this behavior coupled
Returns:
true if this behavior must be executed/rendered
See Also:
IBehavior.isEnabled(Component)

isTemporary

public boolean isTemporary()
Description copied from interface: IBehavior
Specifies whether or not this behavior is temporary. Temporary behaviors are removed at the end of request. Such behaviors are useful for modifying component rendering only when it renders next. Usecases include javascript effects, initial clientside dom setup, etc.

Specified by:
isTemporary in interface IBehavior
Returns:
true if this behavior is temporary
See Also:
IBehavior.isTemporary()

detachModel

public final void detachModel(Component component)
Deprecated. replaced by detach(Component)

Parameters:
component -

rendered

public final void rendered(Component component)
Deprecated. replaced by afterRender(Component)

Parameters:
component -


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