001 // Copyright 2012 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry5.runtime; 016 017 /** 018 * Defines a way for different aspects of a page to add callbacks for important lifecycle events. 019 * 020 * @see org.apache.tapestry5.ComponentResources#getPageLifecycleCallbackHub() 021 * @since 5.3.4 022 */ 023 public interface PageLifecycleCallbackHub 024 { 025 /** 026 * Adds a callback for when the page is first loaded. Callbacks are invoked in the order they 027 * are added to the page. They are invoked once and then discarded. 028 * 029 * @param callback 030 * invoked once, when page is first loaded 031 * @since 5.3.4 032 */ 033 void addPageLoadedCallback(Runnable callback); 034 035 /** 036 * Adds a callback for when the page is attached to the request. 037 * 038 * @param callback 039 * @since 5.3.4 040 */ 041 void addPageAttachedCallback(Runnable callback); 042 043 /** 044 * Adds a callback for when the page is detached from the request. 045 * 046 * @param callback 047 * @since 5.3.4 048 */ 049 void addPageDetachedCallback(Runnable callback); 050 051 /** 052 * Adds a verify callback, which is allowed while the page is loading. Such callbacks are invoked once, 053 * after the page has been loaded successfully, and are then discarded. This was added specifically to ensure that components 054 * only verify that required parameters are bound after all components and mixins of the page have had a chance 055 * to initialize. 056 * 057 * @param callback 058 * to be invoked after page loaded 059 * @since 5.3 060 */ 061 void addVerifyCallback(Runnable callback); 062 063 /** 064 * A reset occurs when a request for a page arrives that did not originate on the same page. This gives the application a chance to reset the state of the page. 065 * 066 * @param callback 067 * invoked when a page is activated by link from some other page. 068 */ 069 void addResetCallback(Runnable callback); 070 }