001    // Copyright 2006, 2008, 2010 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;
016    
017    /**
018     * Callback interface for a {@linkplain org.apache.tapestry5.runtime.Event render phase event} or
019     * 
020     * {@link org.apache.tapestry5.runtime.ComponentEvent}, notified when a non-null value is returned from some event
021     *       handler method.
022     */
023    public interface ComponentEventCallback<T>
024    {
025        /**
026         * Invoked to handle a non-null event handler method result. The handler should determine whether the value is
027         * acceptable, and throw an exception if not. Any thrown exception will be wrapped to identify the component and
028         * method from which the value was returned.
029         * <p/>
030         * Boolean values are <em>not</em> passed to the callback. Booleans are used to indicate that the event has been
031         * handled (true, meaning the event is handled and aborted) or that a further search for handlers should continue
032         * (false, meaning the event was not handled, is not aborted, and the search up the component hierarchy for event
033         * handler methods should continue). If a component event method returns true, then
034         * {@link org.apache.tapestry5.runtime.Event#isAborted()} will return true.
035         * 
036         * @param result
037         *            the result value returned from the event handler method
038         * @return true if the event is aborted, false if the event may continue
039         */
040        boolean handleResult(T result);
041    }