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