KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > forms > formmodel > FormDefinitionBuilder


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 JavaDoc;
23
24 /**
25  * Builds {@link FormDefinition}s.
26  *
27  * @version $Id: FormDefinitionBuilder.java 289538 2005-09-16 13:46:22Z sylvain $
28  */

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 JavaDoc widgetElement, WidgetDefinitionBuilderContext context) throws Exception JavaDoc {
40         throw new UnsupportedOperationException JavaDoc("Please use the other signature without WidgetDefinitionBuilderContext!");
41     }
42     
43     public WidgetDefinition buildWidgetDefinition(Element JavaDoc formElement) throws Exception JavaDoc {
44         FormDefinition formDefinition = new FormDefinition(libraryManager);
45         this.context = new WidgetDefinitionBuilderContext();
46         this.context.setLocalLibrary(formDefinition.getLocalLibrary());
47         
48         // set local URI
49
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