This class allows a tag attribute of a component to be modified dynamically with a value obtained from a model object. This concept can be used to programmatically alter the attributes of components, overriding the values specified in the markup. The two primary uses of this class are to allow overriding of markup attributes based on business logic and to support dynamic localization. The replacement occurs as the component tag is rendered to the response.
The attribute whose value is to be modified must be given on construction of the instance of this class along with the model containing the value to replace with.
If an attribute is not in the markup, this modifier will add an attribute.
Instances of this class should be added to components via the {@link Component#add(Behavior)}method after the component has been constructed.
It is possible to create new subclasses of {@code AttributeModifier} by overriding the{@link #newValue(String,String)} method. For example, you could create an{@code AttributeModifier} subclass which appends the replacement value like this:
new AttributeModifier("myAttribute", model) { protected String newValue(final String currentValue, final String replacementValue) { return currentValue + replacementValue; } };
@author Chris Turner
@author Eelco Hillenius
@author Jonathan Locke
@author Martijn Dashorst
@author Ralf Ebert