|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.behavior.Behavior org.apache.wicket.AttributeModifier org.apache.wicket.behavior.AttributeAppender
public class AttributeAppender
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", Model.of("hot"))); link.add(new AttributeAppender("onmouseover", Model.of("foo();return false;")).setSeparator(";"));this will result in the following markup:
<a href="#" wicket:id="foo" class="link hot" onmouseover="doSomething();foo();return false;">
AttributeModifier.append(String, IModel)
,
AttributeModifier.append(String, Serializable)
,
AttributeModifier.prepend(String, IModel)
,
AttributeModifier.prepend(String, Serializable)
,
Serialized FormField Summary |
---|
Fields inherited from class org.apache.wicket.AttributeModifier |
---|
VALUELESS_ATTRIBUTE_ADD, VALUELESS_ATTRIBUTE_REMOVE |
Constructor Summary | |
---|---|
AttributeAppender(String attribute,
boolean addAttributeIfNotPresent,
IModel<?> appendModel,
String separator)
Deprecated. use AttributeAppender(String, IModel) instead. |
|
AttributeAppender(String attribute,
IModel<?> replaceModel)
Creates an attribute modifier that concatenates the replaceModel to the attribute's
current value, optionally separated by the separator . |
|
AttributeAppender(String attribute,
IModel<?> appendModel,
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. |
|
AttributeAppender(String attribute,
Serializable value)
Creates an attribute modifier that appends the value to the attribute's current
value, optionally separated by the separator . |
|
AttributeAppender(String attribute,
Serializable value,
String separator)
Creates an AttributeModifier that appends the value to the current value of the attribute, and will add the attribute when it is not there already. |
Method Summary | |
---|---|
String |
getSeparator()
Gets the separator used by attribute appenders and prependers. |
protected String |
newValue(String currentValue,
String appendValue)
Gets the value that should replace the current attribute value. |
AttributeAppender |
setSeparator(String separator)
Sets the separator used by attribute appenders and prependers. |
String |
toString()
|
Methods inherited from class org.apache.wicket.AttributeModifier |
---|
append, append, detach, getAttribute, getReplaceModel, onComponentTag, prepend, prepend, remove, replace, replace, replaceAttributeValue |
Methods inherited from class org.apache.wicket.behavior.Behavior |
---|
afterRender, beforeRender, bind, canCallListenerInterface, getStatelessHint, isEnabled, isTemporary, onConfigure, onEvent, onException, onRemove, renderHead, unbind |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public AttributeAppender(String attribute, boolean addAttributeIfNotPresent, IModel<?> appendModel, String separator)
AttributeAppender(String, IModel)
instead.
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 valuepublic AttributeAppender(String attribute, IModel<?> replaceModel)
replaceModel
to the attribute's
current value, optionally separated by the separator
.
attribute
- replaceModel
- public AttributeAppender(String attribute, Serializable value)
value
to the attribute's current
value, optionally separated by the separator
.
attribute
- value
- public AttributeAppender(String attribute, Serializable value, String separator)
attribute
- the attribute to append the appendModels value tovalue
- the value to appendseparator
- the separator string, comes between the original value and the append valuepublic AttributeAppender(String attribute, IModel<?> appendModel, String separator)
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 valueMethod Detail |
---|
public String getSeparator()
public AttributeAppender setSeparator(String separator)
separator
- a space, semicolon or other character used to separate the current value and the
appended/prepended value.
protected String newValue(String currentValue, String appendValue)
AttributeModifier
newValue
in class AttributeModifier
currentValue
- The current attribute value. This value might be null!appendValue
- The replacement value. This value might be null!
public String toString()
toString
in class AttributeModifier
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |