01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.runtime;
16:
17: import org.apache.tapestry.MarkupWriter;
18: import org.apache.tapestry.annotations.OnEvent;
19:
20: /**
21: * Interface that defining the lifecycle of a component, within a page, allowing for callbacks into
22: * the component for many different events. This interface is part of the public API for Tapestry,
23: * but is <em>not</em> expected to be directly implemented by component classes; it should only be
24: * implemented as part of the component class transformation process.
25: * <p>
26: * Most of the methods are related to render phases; see the corresponding annotations and component
27: * rendering documentation to see how they relate to each other.
28: * <p>
29: * This interface is likely to change without notice.
30: */
31: public interface Component extends ComponentResourcesAware,
32: PageLifecycleListener {
33:
34: /**
35: * Lifecycle method invoked at the end of the
36: * {@link org.apache.tapestry.annotations.CleanupRender} render phase. There is no annotation
37: * for this method, it is part of CleanupRender, but is always invoked. Its specific use is to
38: * allow components to clean up cached parameter values.
39: */
40: void postRenderCleanup();
41:
42: /**
43: * Invoked before rendering a component (or its template).
44: */
45: void setupRender(MarkupWriter writer, Event event);
46:
47: /**
48: * Invoked to allow a component to render its tag (start tag and attributes).
49: */
50: void beginRender(MarkupWriter writer, Event event);
51:
52: /**
53: * This phase is only invoked for components with templates.
54: */
55: void beforeRenderTemplate(MarkupWriter writer, Event event);
56:
57: /** Invoked after rendering the template for a component (only for components with a template). */
58: void afterRenderTemplate(MarkupWriter writer, Event event);
59:
60: /**
61: * Invoked just before rendering the body of component.
62: */
63: void beforeRenderBody(MarkupWriter writer, Event event);
64:
65: /** Invoked just after rendering the body of the component. */
66: void afterRenderBody(MarkupWriter writer, Event event);
67:
68: /**
69: * Generally used to write the close tag matching any open tag written by
70: * {@link #beginRender(MarkupWriter, LifecycleEvent)}.
71: */
72: void afterRender(MarkupWriter writer, Event event);
73:
74: /**
75: * Generally used to perform final cleanup of the component after rendering.
76: */
77: void cleanupRender(MarkupWriter writer, Event event);
78:
79: /**
80: * Invoked to handle a component event. Methods with the {@link OnEvent} annotation will be
81: * invoked until one returns a non-null value.
82: *
83: * @param event
84: * @return true if any handler was found (and invoked), false otherwise
85: */
86: boolean handleComponentEvent(ComponentEvent event);
87: }
|