All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 closure;
  
  public XAttributeModifier(final String attributeName, final Function1 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