|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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", new Model<String>("hot"), " ")); link.add(new AttributeAppender("onmouseover", new Model<String>("foo();return false;"), ";"));this will result in the following markup:
<a href="#" wicket:id="foo" class="link hot" onmouseover="doSomething();foo();return false;">AttributeAppenders can also be instructed to prepend the given value:
link.add(new AttributeAppender("class", new Model<String>("hot"), " ", true)); link.add(new AttributeAppender("onmouseover", new Model<String>("foo();return false;"), ";", true));this will result in the following markup:
<a href="#" wicket:id="foo" class="hot link" onmouseover="foo();return false;doSomething();">This is useful for instance to add a Javascript confirmation dialog before performing an action.
Field 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)
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(String attribute,
boolean addAttributeIfNotPresent,
IModel<?> appendModel,
String separator,
boolean prepend)
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(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,
IModel<?> appendModel,
String separator,
boolean prepend)
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 String |
newValue(String currentValue,
String appendValue)
Gets the value that should replace the current attribute value. |
Methods inherited from class org.apache.wicket.AttributeModifier |
---|
detach, getAddAttributeIfNotPresent, getAttribute, getPattern, getReplaceModel, isEnabled, onComponentTag, replaceAttributeValue, setEnabled, toString |
Methods inherited from class org.apache.wicket.behavior.Behavior |
---|
afterRender, beforeRender, bind, canCallListenerInterface, getStatelessHint, isTemporary, onConfigure, onEvent, onException, renderHead, unbind |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AttributeAppender(String attribute, boolean addAttributeIfNotPresent, IModel<?> appendModel, String separator)
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, boolean addAttributeIfNotPresent, IModel<?> appendModel, String separator, boolean prepend)
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 valueprepend
- if true, the attribute modifier will prepend the attribute with the appendModelpublic 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 valuepublic AttributeAppender(String attribute, IModel<?> appendModel, String separator, boolean prepend)
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 valueprepend
- if true, the attribute modifier will prepend the attribute with the appendModelMethod Detail |
---|
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!
AttributeModifier.newValue(java.lang.String, java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |