1 16 package org.apache.cocoon.forms.formmodel; 17 18 import java.util.Iterator ; 19 20 import org.apache.cocoon.forms.FormsConstants; 21 import org.apache.cocoon.forms.event.ValueChangedListener; 22 import org.apache.cocoon.forms.util.DomHelper; 23 import org.w3c.dom.Element ; 24 25 30 public final class BooleanFieldDefinitionBuilder extends AbstractWidgetDefinitionBuilder { 31 public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception { 32 33 BooleanFieldDefinition definition = new BooleanFieldDefinition(); 34 35 setupDefinition(widgetElement, definition); 36 setDisplayData(widgetElement, definition); 37 Iterator iter = buildEventListeners(widgetElement, "on-value-changed", ValueChangedListener.class).iterator(); 38 while (iter.hasNext()) { 39 definition.addValueChangedListener((ValueChangedListener)iter.next()); 40 } 41 42 Element initialValueElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "initial-value", false); 44 if (initialValueElement != null) { 45 Boolean initialValue = Boolean.valueOf(DomHelper.getElementText(initialValueElement)); 46 definition.setInitialValue(initialValue); 47 } 48 49 Element trueParamElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "true-param-value", false); 51 if (trueParamElement != null) { 52 definition.setTrueParamValue(DomHelper.getElementText(trueParamElement)); 53 } 54 55 definition.makeImmutable(); 56 return definition; 57 } 58 } 59 | Popular Tags |