use of org.apache.wicket.util.value.IValueMap in project wicket by apache.
the class AttributeModifier method replaceAttributeValue.
/**
* Checks the given component tag for an instance of the attribute to modify and if all criteria
* are met then replace the value of this attribute with the value of the contained model
* object.
*
* @param component
* The component
* @param tag
* The tag to replace the attribute value for
*/
public final void replaceAttributeValue(final Component component, final ComponentTag tag) {
if (isEnabled(component)) {
final IValueMap attributes = tag.getAttributes();
final Object replacementValue = getReplacementOrNull(component);
if (VALUELESS_ATTRIBUTE_ADD == replacementValue) {
attributes.put(attribute, null);
} else if (VALUELESS_ATTRIBUTE_REMOVE == replacementValue) {
attributes.remove(attribute);
} else {
final String value = toStringOrNull(attributes.get(attribute));
final Serializable newValue = newValue(value, toStringOrNull(replacementValue));
if (newValue == VALUELESS_ATTRIBUTE_REMOVE) {
attributes.remove(attribute);
} else if (newValue != null) {
attributes.put(attribute, newValue);
}
}
}
}
use of org.apache.wicket.util.value.IValueMap in project gitblit by gitblit.
the class ShockWaveComponent method onComponentTag.
@Override
public void onComponentTag(ComponentTag tag) {
// get options from the markup
IValueMap valueMap = tag.getAttributes();
// Iterate over valid options
for (String s : optionNames) {
if (valueMap.containsKey(s)) {
// if option isn't set programmatically, set value from markup
if (!attributes.containsKey(s) && !parameters.containsKey(s))
setValue(s, valueMap.getString(s));
// remove attribute - they are added in super.onComponentTag()
// to
// the right place as attribute or param
valueMap.remove(s);
}
}
super.onComponentTag(tag);
}
use of org.apache.wicket.util.value.IValueMap in project wicket by apache.
the class NumberTextField method onComponentTag.
@Override
protected void onComponentTag(final ComponentTag tag) {
super.onComponentTag(tag);
IValueMap attributes = tag.getAttributes();
final N min = minimum.getObject();
if (min != null) {
attributes.put("min", Objects.stringValue(min));
} else {
attributes.remove("min");
}
final N max = maximum.getObject();
if (max != null) {
attributes.put("max", Objects.stringValue(max));
} else {
attributes.remove("max");
}
final N _step = step.getObject();
if (_step != null) {
if (_step.doubleValue() == ANY) {
attributes.put("step", "any");
} else {
attributes.put("step", Objects.stringValue(_step));
}
} else {
attributes.remove("step");
}
}
use of org.apache.wicket.util.value.IValueMap in project wicket by apache.
the class WicketMessageResolver method resolve.
@Override
public Component resolve(final MarkupContainer container, final MarkupStream markupStream, final ComponentTag tag) {
if (tag instanceof WicketTag) {
WicketTag wtag = (WicketTag) tag;
if (wtag.isMessageTag()) {
IValueMap attributes = wtag.getAttributes();
String messageKey = attributes.getString(KEY_ATTRIBUTE);
if (Strings.isEmpty(messageKey)) {
throw new MarkupException("Wrong format of <wicket:message key='xxx'>: attribute 'key' is missing");
}
boolean escape = attributes.getBoolean(ESCAPE_ATTRIBUTE);
final String id = wtag.getId();
MessageContainer label = new MessageContainer(id, messageKey, escape);
label.setRenderBodyOnly(container.getApplication().getMarkupSettings().getStripWicketTags());
return label;
}
}
// We were not able to handle the tag
return null;
}
use of org.apache.wicket.util.value.IValueMap in project wicket by apache.
the class TagTester method getAttribute.
/**
* Gets the value for a given attribute. Please note that this is non case-sensitive, because
* attributes in HTML may be non case-sensitive.
*
* @param attribute
* an attribute to look for in the tag
* @return the value of the attribute or <code>null</code> if it isn't found.
*/
public String getAttribute(String attribute) {
String value = null;
IValueMap attributeMap = openTag.getAttributes();
if (attributeMap != null) {
for (String attr : attributeMap.keySet()) {
if (attr.equalsIgnoreCase(attribute)) {
value = attributeMap.getString(attr);
}
}
}
return value;
}
Aggregations