| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Component |
|
| 1.0;1 |
| 1 | // Copyright 2006, 2009 The Apache Software Foundation | |
| 2 | // | |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | // you may not use this file except in compliance with the License. | |
| 5 | // You may obtain a copy of the License at | |
| 6 | // | |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | // | |
| 9 | // 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.tapestry5.runtime; | |
| 16 | ||
| 17 | import org.apache.tapestry5.MarkupWriter; | |
| 18 | import org.apache.tapestry5.annotations.OnEvent; | |
| 19 | ||
| 20 | /** | |
| 21 | * Interface that defines the lifecycle of a component, within a page, allowing for callbacks into the component for | |
| 22 | * many different events. This interface is part of the public API for Tapestry, but is <em>not</em> expected to be | |
| 23 | * directly implemented by component classes; it should only be implemented as part of the component class | |
| 24 | * transformation process. | |
| 25 | * <p/> | |
| 26 | * Most of the methods are related to render phases; see the corresponding annotations and component rendering | |
| 27 | * documentation to see how they relate to each other. | |
| 28 | */ | |
| 29 | public interface Component extends ComponentResourcesAware, PageLifecycleListener | |
| 30 | { | |
| 31 | ||
| 32 | /** | |
| 33 | * Lifecycle method invoked at the end of the {@link org.apache.tapestry5.annotations.CleanupRender} render phase. | |
| 34 | * There is no annotation for this method, it is part of CleanupRender, but is always invoked. Its specific use is | |
| 35 | * to allow components to clean up cached parameter values. | |
| 36 | */ | |
| 37 | void postRenderCleanup(); | |
| 38 | ||
| 39 | /** | |
| 40 | * Invoked before rendering a component (or its template). | |
| 41 | */ | |
| 42 | void setupRender(MarkupWriter writer, Event event); | |
| 43 | ||
| 44 | /** | |
| 45 | * Invoked to allow a component to render its tag (start tag and attributes). | |
| 46 | */ | |
| 47 | void beginRender(MarkupWriter writer, Event event); | |
| 48 | ||
| 49 | /** | |
| 50 | * This phase is only invoked for components with templates. | |
| 51 | */ | |
| 52 | void beforeRenderTemplate(MarkupWriter writer, Event event); | |
| 53 | ||
| 54 | /** | |
| 55 | * Invoked after rendering the template for a component (only for components with a template). | |
| 56 | */ | |
| 57 | void afterRenderTemplate(MarkupWriter writer, Event event); | |
| 58 | ||
| 59 | /** | |
| 60 | * Invoked just before rendering the body of component. | |
| 61 | */ | |
| 62 | void beforeRenderBody(MarkupWriter writer, Event event); | |
| 63 | ||
| 64 | /** | |
| 65 | * Invoked just after rendering the body of the component. | |
| 66 | */ | |
| 67 | void afterRenderBody(MarkupWriter writer, Event event); | |
| 68 | ||
| 69 | /** | |
| 70 | * Generally used to write the close tag matching any open tag written by {@link | |
| 71 | * #beginRender(org.apache.tapestry5.MarkupWriter, Event)}. | |
| 72 | */ | |
| 73 | void afterRender(MarkupWriter writer, Event event); | |
| 74 | ||
| 75 | /** | |
| 76 | * Generally used to perform final cleanup of the component after rendering. | |
| 77 | */ | |
| 78 | void cleanupRender(MarkupWriter writer, Event event); | |
| 79 | ||
| 80 | /** | |
| 81 | * Invoked to handle a component event. Methods with the {@link OnEvent} annotation (or the matching naming | |
| 82 | * convention) will be invoked until one returns a non-null value. | |
| 83 | * | |
| 84 | * @param event | |
| 85 | * @return true if any handler was found (and invoked), false otherwise | |
| 86 | * @throws RuntimeException wrapping any checked exceptions that are thrown by individual event handler methods | |
| 87 | */ | |
| 88 | boolean dispatchComponentEvent(ComponentEvent event); | |
| 89 | } |