001    // Copyright Aug 27, 2006 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    package org.apache.tapestry;
015    
016    import java.util.Collection;
017    
018    
019    /**
020     * Represents "something" that can cause dynamic XHR/JSON requests to be executed
021     * as a result of whatever actions the thing that it is attached to normally 
022     * does.
023     * 
024     * <p>
025     * This interface is more commonly implemented by components like {@link DirectLink} or
026     * {@Form} to decorate existing functionality.
027     * </p>
028     * 
029     * @author jkuhnert
030     */
031    public interface IDynamicInvoker
032    {
033        
034        /**
035         * If set, will be used to update/refresh portions of a response during XHR requests.
036         * 
037         * <p>
038         *  For instance, if you have a page listing projects and you wanted to update an 
039         *  {@link Any} components contents whenever one of the project links was clicked 
040         *  you would use a {@link DirectLink} with the parameters:
041         * </p>
042         * 
043         * <pre>
044         *      updateComponents="{'projectDetails'}"
045         *      async="true"
046         * </pre>
047         * 
048         * @return The list of components to update, if any.
049         */
050        Collection getUpdateComponents();
051        
052        /**
053         * Used to specify whether or not the result of this invocation should be returned asynchronously
054         * or use normal browser page reload semantics. 
055         * 
056         * <p>
057         *  Async being true means responses will be encoded as XML using XmlHttpRequests. If you would like
058         *  your request/response to be in another format - like JSON - you must also specify the additional 
059         *  parameter {@link #isJson()}.  Without setting the {@link #getUpdateComponents()} parameter
060         * this parameter is pretty useless.
061         * </p>
062         * 
063         * @see #isJson()
064         * @return True if invocation should be processed asynchronously.
065         */
066        boolean isAsync();
067        
068        /**
069         * Used to specify that the return invocation of the response created should be in the
070         * {@linkplain http://json.org} format. Without setting the {@link #getUpdateComponents()} parameter
071         * this parameter is pretty useless.
072         * 
073         * @see {@link org.apache.IJSONRender}
074         * @return True if response should be encoded using JSON semantics.
075         */
076        boolean isJson();
077    }