KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > formmodel > FormDefinition


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.woody.formmodel;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.List JavaDoc;
20
21 import org.apache.cocoon.woody.event.ProcessingPhaseEvent;
22 import org.apache.cocoon.woody.event.ProcessingPhaseListener;
23 import org.apache.cocoon.woody.event.WidgetEventMulticaster;
24
25 /**
26  * The {@link WidgetDefinition} part of a Form widget, see {@link Form} for more information.
27  *
28  * @version $Id: FormDefinition.java 30932 2004-07-29 17:35:38Z vgritsenko $
29  */

30 public class FormDefinition extends AbstractContainerDefinition {
31     private ProcessingPhaseListener listener;
32
33     public FormDefinition() {
34         super();
35     }
36
37     public void resolve() throws Exception JavaDoc {
38         List JavaDoc parents = new ArrayList JavaDoc();
39         parents.add(this);
40         resolve(parents, this);
41     }
42
43     public Widget createInstance() {
44         Form form = new Form(this);
45         createWidgets(form);
46         return form;
47     }
48     
49     public void addProcessingPhaseListener(ProcessingPhaseListener listener) {
50         this.listener = WidgetEventMulticaster.add(this.listener, listener);
51     }
52     
53     public boolean hasProcessingPhaseListeners() {
54         return this.listener != null;
55     }
56     
57     public void fireEvent(ProcessingPhaseEvent event) {
58         if (this.listener != null) {
59             this.listener.phaseEnded(event);
60         }
61     }
62 }
63
Popular Tags