wicket.behavior
Interface IBehavior

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractAjaxBehavior, AbstractAjaxTimerBehavior, AbstractBehavior, AbstractDefaultAjaxBehavior, AbstractHeaderContributor, AbstractTransformerBehavior, AjaxEventBehavior, AjaxFormComponentUpdatingBehavior, AjaxFormSubmitBehavior, AjaxFormValidatingBehavior, AjaxPagingNavigationBehavior, AjaxSelfUpdatingTimerBehavior, AttributeAppender, AttributeModifier, BodyContainer.AppendingAttributeModifier, BodyTagAttributeModifier, HeaderContributor, HeaderContributor.CSSHeaderContributor, HeaderContributor.JavaScriptHeaderContributor, SimpleAttributeModifier, StringHeaderContributor, XsltTransfomerBehavior

public interface IBehavior
extends java.io.Serializable

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
See Also:
IBehaviorListener, IHeaderContributor, AbstractAjaxBehavior, AttributeModifier

Method Summary
 void bind(Component component)
          Bind this handler to the given component.
 void detachModel(Component component)
          Provides for the ability to detach any models this behavior has.
 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.
 void onComponentTag(Component component, ComponentTag tag)
          Called any time a component that has this behavior registered is rendering the component tag.
 void rendered(Component component)
          Called when a component that has this behavior coupled was rendered.
 

Method Detail

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 can 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

detachModel

void detachModel(Component component)
Provides for the ability to detach any models this behavior has. This method is called by the components which have this behavior attached to them when they are detaching their models themselves (ie after rendering). Note that if you share a behavior between components, this method is called multiple times. YOU MUST CALL SUPER WHEN IMPLEMENTING THIS METHOD

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

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

rendered

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

Parameters:
component - the component that has this behavior coupled

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 rendered(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 occured
exception - the unexpected exception


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