org.apache.wicket.behavior
Interface IBehavior

All Superinterfaces:
IClusterable, java.io.Serializable
All Known Implementing Classes:
AbstractAjaxBehavior, AbstractAjaxTimerBehavior, AbstractAutoCompleteBehavior, AbstractBehavior, AbstractDefaultAjaxBehavior, AbstractHeaderContributor, AbstractTransformerBehavior, AjaxEditableLabel.EditorAjaxBehavior, AjaxEditableLabel.LabelAjaxBehavior, AjaxEventBehavior, AjaxFormChoiceComponentUpdatingBehavior, AjaxFormComponentUpdatingBehavior, AjaxFormSubmitBehavior, AjaxFormValidatingBehavior, AjaxPagingNavigationBehavior, AjaxSelfUpdatingTimerBehavior, AttributeAppender, AttributeModifier, AutoCompleteBehavior, BodyTagAttributeModifier, ContainerWithAssociatedMarkupHelper, DatePicker, HeaderContributor, OnChangeAjaxBehavior, OrderByLink.CssModifier, SimpleAttributeModifier, StringHeaderContributor, TextTemplateHeaderContributor, VelocityContributor, VelocityHeaderContributor, VelocityJavascriptContributor, WicketAjaxIndicatorAppender, WicketMessageTagHandler.AttributeLocalizer, XsltTransformerBehavior

public interface IBehavior
extends IClusterable

Behaviors are kind of plug-ins for Components. They allow to be added to a component and get essential events forwarded by the component. they can be bound to a concrete component (using the bind method is called when the behavior is attached), but they don't need to. They can modify the components markup by changing the rendered ComponentTag. Behaviors can have their own models as well, and they are notified when these are to be detached by the component.

It is recommended that you extend from AbstractBehavior instead of directly implementing this interface.

Author:
Ralf Ebert, Eelco Hillenius, Igor Vaynberg (ivaynberg)
See Also:
IBehaviorListener, IHeaderContributor, AbstractAjaxBehavior, AttributeModifier

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 detach(Component component)
          Allows the behavior to detach any state it has attached during request processing.
 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.
 

Method Detail

beforeRender

void beforeRender(Component component)
Called when a component is about to render.

Parameters:
component - the component that has this behavior coupled

afterRender

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

Parameters:
component - the component that has this behavior coupled

bind

void bind(Component component)
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.

Parameters:
component - the component to bind to

detach

void detach(Component component)
Allows the behavior to detach any state it has attached during request processing.

Parameters:
component - the component that initiates the detachment of this behavior

exception

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. Typically, if you clean up resources in afterRender(Component), you should do the same in the implementation of this method.

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

getStatelessHint

boolean getStatelessHint(Component component)
This method returns false if the behavior generates a callback url (for example ajax behaviors)

Parameters:
component - the component that has this behavior coupled.
Returns:
boolean true or false.

isEnabled

boolean isEnabled(Component component)
Called when a components is rendering and wants to render this behavior. If false is returned this behavior will be ignored.

Parameters:
component - the component that has this behavior coupled
Returns:
true if this behavior must be executed/rendered

onComponentTag

void onComponentTag(Component component,
                    ComponentTag tag)
Called any time a component that has this behavior registered is rendering the component tag.

Parameters:
component - the component that renders this tag currently
tag - the tag that is rendered

isTemporary

boolean isTemporary()
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.

Returns:
true if this behavior is temporary


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