01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.woody.formmodel;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.apache.cocoon.woody.event.ProcessingPhaseEvent;
23: import org.apache.cocoon.woody.event.ProcessingPhaseListener;
24: import org.apache.cocoon.woody.event.WidgetEventMulticaster;
25:
26: /**
27: * The {@link WidgetDefinition} part of a Form widget, see {@link Form} for more information.
28: *
29: * @version $Id: FormDefinition.java 433543 2006-08-22 06:22:54Z crossley $
30: */
31: public class FormDefinition extends AbstractContainerDefinition {
32: private ProcessingPhaseListener listener;
33:
34: public FormDefinition() {
35: super ();
36: }
37:
38: public void resolve() throws Exception {
39: List parents = new ArrayList();
40: parents.add(this );
41: resolve(parents, this );
42: }
43:
44: public Widget createInstance() {
45: Form form = new Form(this );
46: createWidgets(form);
47: return form;
48: }
49:
50: public void addProcessingPhaseListener(
51: ProcessingPhaseListener listener) {
52: this .listener = WidgetEventMulticaster.add(this .listener,
53: listener);
54: }
55:
56: public boolean hasProcessingPhaseListeners() {
57: return this .listener != null;
58: }
59:
60: public void fireEvent(ProcessingPhaseEvent event) {
61: if (this.listener != null) {
62: this.listener.phaseEnded(event);
63: }
64: }
65: }
|