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

org.uqbar.wicket.xtend.XAttributeModifier.xtend 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

/**
 * 
 * @author jfernandes
 */
class XAttributeModifier extends Behavior {
	String attributeName
	(T)=>String closure
	
	new(String attributeName, (T)=>String closure) {
		this.attributeName = attributeName
		this.closure = closure
	}
	
	override onComponentTag(Component component, ComponentTag tag) {
		super.onComponentTag(component, tag)
		val model = component.defaultModelObject
		val attributeValue = closure.apply(model as T)
		
		tag.attributes.put(attributeName, attributeValue)
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy