org.uqbar.wicket.xtend.XAttributeModifier Maven / Gradle / Ivy
package org.uqbar.wicket.xtend;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.util.value.IValueMap;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
/**
* @author jfernandes
*/
@SuppressWarnings("all")
public class XAttributeModifier extends Behavior {
private String attributeName;
private Function1 super T, ? extends String> closure;
public XAttributeModifier(final String attributeName, final Function1 super T, ? extends String> closure) {
this.attributeName = attributeName;
this.closure = closure;
}
public void onComponentTag(final Component component, final ComponentTag tag) {
super.onComponentTag(component, tag);
final Object model = component.getDefaultModelObject();
final String attributeValue = this.closure.apply(((T) model));
IValueMap _attributes = tag.getAttributes();
_attributes.put(this.attributeName, attributeValue);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy