wicket.behavior
Class AttributeAppender
java.lang.Object
wicket.behavior.AbstractBehavior
wicket.AttributeModifier
wicket.behavior.AttributeAppender
- All Implemented Interfaces:
- java.io.Serializable, IBehavior
public class AttributeAppender
- extends AttributeModifier
AttributeModifier that appends the given value, rather than replace it. This
is especially useful for adding CSS classes to markup elements, or adding
JavaScript snippets to existing element handlers.
<a href="#" wicket:id="foo" class="link" onmouseover="doSomething()">
can be modified with these AttributeAppenders:
link.add(new AttributeAppender("class", new Model("hot"), " "));
link.add(new AttributeAppender("onmouseover", new Model("foo();return false;"), ";"));
this will result in the following markup:
<a href="#" wicket:id="foo" class="link hot" onmouseover="doSomething();foo();return false;">
- Author:
- Martijn Dashorst
- See Also:
- Serialized Form
Constructor Summary |
AttributeAppender(java.lang.String attribute,
boolean addAttributeIfNotPresent,
IModel appendModel,
java.lang.String separator)
Creates an AttributeModifier that appends the appendModel's value to the
current value of the attribute, and will add the attribute when
addAttributeIfNotPresent is true. |
AttributeAppender(java.lang.String attribute,
IModel appendModel,
java.lang.String separator)
Creates an AttributeModifier that appends the appendModel's value to the
current value of the attribute, and will add the attribute when it is not
there already. |
Method Summary |
protected java.lang.String |
newValue(java.lang.String currentValue,
java.lang.String appendValue)
Gets the value that should replace the current attribute value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
AttributeAppender
public AttributeAppender(java.lang.String attribute,
boolean addAttributeIfNotPresent,
IModel appendModel,
java.lang.String separator)
- Creates an AttributeModifier that appends the appendModel's value to the
current value of the attribute, and will add the attribute when
addAttributeIfNotPresent is true.
- Parameters:
attribute
- the attribute to append the appendModels value toaddAttributeIfNotPresent
- when true, adds the attribute to the tagappendModel
- the model supplying the value to appendseparator
- the separator string, comes between the original value and the
append value
AttributeAppender
public AttributeAppender(java.lang.String attribute,
IModel appendModel,
java.lang.String separator)
- Creates an AttributeModifier that appends the appendModel's value to the
current value of the attribute, and will add the attribute when it is not
there already.
- Parameters:
attribute
- the attribute to append the appendModels value toappendModel
- the model supplying the value to appendseparator
- the separator string, comes between the original value and the
append value
newValue
protected java.lang.String newValue(java.lang.String currentValue,
java.lang.String appendValue)
- 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!appendValue
- 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-2007 Wicket developers. All Rights Reserved.