1 16 package org.apache.cocoon.forms.formmodel; 17 18 import java.util.Iterator ; 19 20 import org.apache.cocoon.forms.event.ValueChangedListener; 21 import org.apache.cocoon.forms.util.DomHelper; 22 import org.w3c.dom.Element ; 23 24 31 public final class UploadDefinitionBuilder extends AbstractWidgetDefinitionBuilder { 32 33 public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception { 34 String mimeTypes = DomHelper.getAttribute(widgetElement, "mime-types", null); 35 36 UploadDefinition uploadDefinition = new UploadDefinition(); 37 super.setupDefinition(widgetElement, uploadDefinition); 38 39 setDisplayData(widgetElement, uploadDefinition); 40 Iterator iter = buildEventListeners(widgetElement, "on-value-changed", ValueChangedListener.class).iterator(); 41 while (iter.hasNext()) { 42 uploadDefinition.addValueChangedListener((ValueChangedListener)iter.next()); 43 } 44 45 46 if(widgetElement.hasAttribute("required")) 47 uploadDefinition.setRequired(DomHelper.getAttributeAsBoolean(widgetElement, "required", false)); 48 49 uploadDefinition.addMimeTypes(mimeTypes); 50 51 uploadDefinition.makeImmutable(); 52 return uploadDefinition; 53 } 54 } 55 | Popular Tags |