Source code: com/voytechs/html/component/DispatchableComponent.java
1 /*
2 * File: DispatchableComponent.java
3 * Auth: Mark Bednarczyk
4 * Date: DATE
5 * Id: $Id: DispatchableComponent.java,v 1.1.1.1 2002/01/23 23:52:49 voytechs Exp $
6 ********************************************
7 * $Log: DispatchableComponent.java,v $
8 * Revision 1.1.1.1 2002/01/23 23:52:49 voytechs
9 * Initial public release, BETA 1.0 - voytechs
10 *
11 */
12 package com.voytechs.html.component;
13
14 import com.voytechs.html.util.LogFacility;
15
16 import com.voytechs.html.event.*;
17 import com.voytechs.html.event.*;
18
19 import java.lang.*;
20 import java.util.*;
21
22 /**
23 * Base class for all form elements.
24 */
25 public abstract class DispatchableComponent
26 extends Component {
27
28 /* Internal attributes */
29
30 private HtmlDispatcherBroker broker = null;
31
32 /**
33 *
34 * @param
35 * @exception
36 */
37 public DispatchableComponent(int componentType) {
38 super();
39
40 broker = new HtmlDispatcherBroker(componentType);
41 }
42
43 /**
44 * Function that initializes the object relationships. Late bindings,
45 * adding delayed listeners, etc. Called after the full component tree
46 * is built.
47 * @param dispatcher Dispatcher object that dispatches events to interested
48 * listeners.
49 */
50 protected void init(Frame root, HtmlDispatcher dispatcher)
51 throws EventException {
52
53 super.init(root, dispatcher);
54
55 broker.setDispatcher(dispatcher);
56
57 setFlags(Component.COMPONENT_FLAG_DISPATCHABLE);
58 }
59
60 /**
61 * Add listener. Can add listeners only after the init method is called which
62 * means that all of the bindings to the dispatcher have already occured and
63 * we can safely register our listener.
64 */
65 protected void addListener(ListenerRequest request) throws EventException {
66 LogFacility.log.println(this + "::DispatchableComponent::addListener() - listener=" + request.getListener());
67
68 broker.addListener(request);
69 }
70
71 /**
72 * Get the uniq name of the component.
73 */
74 protected String getElementName() {
75 return(broker.getElementName());
76 }
77
78 /**
79 * Get event ID
80 * @return Uniq event ID.
81 */
82 public int getElementId() throws EventException {
83 LogFacility.log.println(this + "::DispatchableComponent::getElementId() - id=" +
84 broker.getId());
85
86 return(broker.getId());
87 }
88
89 /**
90 * Get eventType.
91 * @return Element type.
92 */
93 public int getElementType() {
94 return(broker.getEventType());
95 }
96
97 /**
98 * Test function for DispatchableComponent
99 * @param args command line arguments
100 */
101 public static void main(String [] args) {
102 }
103
104 } /* END OF: DispatchableComponent */