1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.cocoon.forms.datatype.SelectionList; 19 import org.apache.cocoon.forms.util.DomHelper; 20 import org.w3c.dom.Element ; 21 22 27 public class FieldDefinitionBuilder extends AbstractDatatypeWidgetDefinitionBuilder { 28 29 public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception { 30 FieldDefinition definition = new FieldDefinition(); 31 setupDefinition(widgetElement, definition); 32 definition.makeImmutable(); 33 return definition; 34 } 35 36 protected void setupDefinition(Element widgetElement, FieldDefinition definition) throws Exception { 37 super.setupDefinition(widgetElement, definition); 38 39 if(widgetElement.hasAttribute("required")) 41 definition.setRequired(DomHelper.getAttributeAsBoolean(widgetElement, "required", false)); 42 43 SelectionList list = buildSelectionList(widgetElement, definition, "suggestion-list"); 44 if (list != null) { 45 definition.setSuggestionList(list); 46 } 47 } 48 } 49 | Popular Tags |