1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.avalon.framework.service.ServiceException; 19 import org.apache.avalon.framework.service.ServiceManager; 20 import org.apache.cocoon.forms.formmodel.library.LibraryManager; 21 import org.apache.cocoon.util.location.LocationAttributes; 22 import org.w3c.dom.Element ; 23 24 29 public final class FormDefinitionBuilder extends AbstractContainerDefinitionBuilder { 30 31 protected LibraryManager libraryManager; 32 33 public void service(ServiceManager manager) throws ServiceException { 34 super.service(manager); 35 36 libraryManager = (LibraryManager) serviceManager.lookup(LibraryManager.ROLE); 37 } 38 39 public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context) throws Exception { 40 throw new UnsupportedOperationException ("Please use the other signature without WidgetDefinitionBuilderContext!"); 41 } 42 43 public WidgetDefinition buildWidgetDefinition(Element formElement) throws Exception { 44 FormDefinition formDefinition = new FormDefinition(libraryManager); 45 this.context = new WidgetDefinitionBuilderContext(); 46 this.context.setLocalLibrary(formDefinition.getLocalLibrary()); 47 48 formDefinition.getLocalLibrary().setSourceURI(LocationAttributes.getURI(formElement)); 50 51 super.setupDefinition(formElement, formDefinition); 52 setDisplayData(formElement, formDefinition); 53 54 setupContainer(formElement,"widgets",formDefinition); 55 56 formDefinition.resolve(); 57 58 formDefinition.makeImmutable(); 59 60 this.context = null; 61 return formDefinition; 62 } 63 } 64 | Popular Tags |