org.apache.wicket.markup.html.body
Class BodyTagAttributeModifier

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      extended by org.apache.wicket.AttributeModifier
          extended by org.apache.wicket.markup.html.body.BodyTagAttributeModifier
All Implemented Interfaces:
java.io.Serializable, IBehavior, IClusterable, IHeaderContributor

public final class BodyTagAttributeModifier
extends AttributeModifier

An attribute modifier specifically for body tags.

Panels have associated markup files and if they contain <wicket:head> and <body onLoad="..."> then the body's onLoad attribute will be appended to the page's onLoad attribute. That accretion happens by means of an AttributeModifier which the Panel adds to the body container. In the case where the Panel is removed or replaced, then the AttributeModifier must be removed or at least disabled. That exactly is what this special purpose AttributeModifier does, i.e. it disables itself if the owner component (Panel) is removed or replaced.

Author:
Juergen Donnerstag
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.AttributeModifier
VALUELESS_ATTRIBUTE_ADD, VALUELESS_ATTRIBUTE_REMOVE
 
Constructor Summary
BodyTagAttributeModifier(java.lang.String attribute, boolean addAttributeIfNotPresent, IModel replaceModel, Component behaviorOwner)
          Create a new attribute modifier with the given attribute name and model to replace with.
BodyTagAttributeModifier(java.lang.String attribute, IModel replaceModel, Component behaviorOwner)
          Create a new attribute modifier with the given attribute name and model to replace with.
BodyTagAttributeModifier(java.lang.String attribute, java.lang.String pattern, boolean addAttributeIfNotPresent, IModel replaceModel, Component behaviorOwner)
          Create a new attribute modifier with the given attribute name and expected pattern to match plus the model to replace with.
BodyTagAttributeModifier(java.lang.String attribute, java.lang.String pattern, IModel replaceModel, Component behaviorOwner)
          Create a new attribute modifier with the given attribute name and expected pattern to match plus the model to replace with.
 
Method Summary
protected  java.lang.String newValue(java.lang.String currentValue, java.lang.String replacementValue)
          Gets the value that should replace the current attribute value.
 
Methods inherited from class org.apache.wicket.AttributeModifier
detach, getAddAttributeIfNotPresent, getAttribute, getContextRelativeValue, getPattern, getReplaceModel, isEnabled, isEnabled, onComponentTag, replaceAttibuteValue, replaceAttributeValue, setEnabled, toString
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, bind, cleanup, detachModel, exception, getStatelessHint, isTemporary, onException, onRendered, rendered, renderHead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BodyTagAttributeModifier

public BodyTagAttributeModifier(java.lang.String attribute,
                                boolean addAttributeIfNotPresent,
                                IModel replaceModel,
                                Component behaviorOwner)
Create a new attribute modifier with the given attribute name and model to replace with. The additional boolean flag specifies whether to add the attribute if it is not present.

Parameters:
attribute - The attribute name to replace the value for
addAttributeIfNotPresent - Whether to add the attribute if it is not present
replaceModel - The model to replace the value with
behaviorOwner - The component which created (owns) the modifier

BodyTagAttributeModifier

public BodyTagAttributeModifier(java.lang.String attribute,
                                IModel replaceModel,
                                Component behaviorOwner)
Create a new attribute modifier with the given attribute name and model to replace with. The attribute will not be added if it is not present.

Parameters:
attribute - The attribute name to replace the value for
replaceModel - The model to replace the value with
behaviorOwner - The component which created (owns) the modifier

BodyTagAttributeModifier

public BodyTagAttributeModifier(java.lang.String attribute,
                                java.lang.String pattern,
                                boolean addAttributeIfNotPresent,
                                IModel replaceModel,
                                Component behaviorOwner)
Create a new attribute modifier with the given attribute name and expected pattern to match plus the model to replace with. A null pattern will match the attribute regardless of its value. The additional boolean flag specifies whether to add the attribute if it is not present.

Parameters:
attribute - The attribute name to replace the value for
pattern - The pattern of the current attribute value to match
addAttributeIfNotPresent - Whether to add the attribute if it is not present and the replacement value is not null
replaceModel - The model to replace the value with
behaviorOwner - The component which created (owns) the modifier

BodyTagAttributeModifier

public BodyTagAttributeModifier(java.lang.String attribute,
                                java.lang.String pattern,
                                IModel replaceModel,
                                Component behaviorOwner)
Create a new attribute modifier with the given attribute name and expected pattern to match plus the model to replace with. A null pattern will match the attribute regardless of its value. The attribute will not be added if it is not present.

Parameters:
attribute - The attribute name to replace the value for
pattern - The pattern of the current attribute value to match
replaceModel - The model to replace the value with
behaviorOwner - The component which created (owns) the modifier
Method Detail

newValue

protected java.lang.String newValue(java.lang.String currentValue,
                                    java.lang.String replacementValue)
Description copied from class: AttributeModifier
Gets the value that should replace the current attribute value. This gives users the ultimate means to customize what will be used as the attribute value. For instance, you might decide to append the replacement value to the current instead of just replacing it as is Wicket's default.

Overrides:
newValue in class AttributeModifier
Parameters:
currentValue - The current attribute value. This value might be null!
replacementValue - The replacement value. This value might be null!
Returns:
The value that should replace the current attribute value
See Also:
AttributeModifier.newValue(java.lang.String, java.lang.String)


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