public abstract class Behavior extends Object implements IClusterable, IComponentAwareEventSink, IComponentAwareHeaderContributor
You also cannot modify a components model with a behavior.
IRequestListener
,
IHeaderContributor
,
AbstractAjaxBehavior
,
AttributeModifier
,
Serialized FormConstructor and Description |
---|
Behavior()
Constructor
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
canCallListener(Component component)
Checks whether or not an
IRequestListener can be invoked on this behavior. |
void |
detach(Component component)
Allows the behavior to detach any state it has attached during request processing.
|
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(Component component)
Specifies whether or not this behavior is temporary.
|
static Behavior |
onAttribute(String name,
org.danekja.java.util.function.serializable.SerializableFunction<String,CharSequence> onAttribute)
Creates a
Behavior that uses the given SerializableFunction function to do
something with a component's attribute. |
void |
onComponentTag(Component component,
ComponentTag tag)
Called any time a component that has this behavior registered is rendering the component tag.
|
void |
onConfigure(Component component)
Called immediately after the onConfigure method in a component.
|
void |
onEvent(Component component,
IEvent<?> event)
Called to notify the behavior about any events sent to the component
|
void |
onException(Component component,
RuntimeException exception)
In case an unexpected exception happened anywhere between
onComponentTag(org.apache.wicket.Component, org.apache.wicket.markup.ComponentTag) and
afterRender(org.apache.wicket.Component),
onException() will be called for any behavior.
|
void |
onRemove(Component component)
Called to notify that the component is being removed from its parent
|
static Behavior |
onTag(org.danekja.java.util.function.serializable.SerializableBiConsumer<Component,ComponentTag> onTagConsumer)
Creates a
Behavior that uses the given SerializableConsumer consumer to do
something with the component's tag. |
void |
renderHead(Component component,
IHeaderResponse response)
Render to the web response whatever the component wants to contribute to the head section.
|
void |
unbind(Component component)
Notifies the behavior it is removed from the specified component
|
public void beforeRender(Component component)
component
- the component that has this behavior coupledpublic void afterRender(Component component)
component
- the component that has this behavior coupledpublic void bind(Component component)
component
- the component to bind topublic void unbind(Component component)
component
- the component this behavior is unbound frompublic void detach(Component component)
component
- the component that initiates the detachment of this behaviorpublic void onException(Component component, RuntimeException exception)
afterRender(Component)
, you should do the same in the implementation of this method.component
- the component that has a reference to this behavior and during which processing
the exception occurredexception
- the unexpected exceptionpublic boolean getStatelessHint(Component component)
component
- the component that has this behavior coupled.public boolean isEnabled(Component component)
component
- the component that has this behavior coupledpublic void onComponentTag(Component component, ComponentTag tag)
component
- the component that renders this tag currentlytag
- the tag that is renderedpublic boolean isTemporary(Component component)
component
- public boolean canCallListener(Component component)
IRequestListener
can be invoked on this behavior. For further
information please read the javadoc on Component.canCallListener()
,
this method has the same semantics.
WARNING: Read the javadoc of Component.canCallListener()
for important
security-related information.component
- component this behavior is attached topublic void renderHead(Component component, IHeaderResponse response)
renderHead
in interface IComponentAwareHeaderContributor
component
- response
- Response objectpublic void onConfigure(Component component)
component
- the component being configuredpublic void onEvent(Component component, IEvent<?> event)
onEvent
in interface IComponentAwareEventSink
component
- component that owns this sink. For example, if the implementation of this
interface is a Behavior
then component parameter will contain the
component to which the behavior is attached.IComponentAwareEventSink.onEvent(org.apache.wicket.Component,
org.apache.wicket.event.IEvent)
public void onRemove(Component component)
component
- the removed componentpublic static Behavior onTag(org.danekja.java.util.function.serializable.SerializableBiConsumer<Component,ComponentTag> onTagConsumer)
Behavior
that uses the given SerializableConsumer consumer
to do
something with the component's tag.
Usage:
component.add(onTag(tag -> tag.put(key, value)));
onTagConsumer
- the SerializableConsumer
that accepts the ComponentTag
public static Behavior onAttribute(String name, org.danekja.java.util.function.serializable.SerializableFunction<String,CharSequence> onAttribute)
Behavior
that uses the given SerializableFunction function
to do
something with a component's attribute.
Usage:
component.add(onAttribute("class",
currentValue -> condition(currentValue) ? "positive" : "negative"));
name
- the name of the attribute to manipulateonAttribute
- the SerializableFunction
that accepts the old value of the attribute and
returns a new valueCopyright © 2006–2022 Apache Software Foundation. All rights reserved.