001 // Copyright 2011 The Apache Software Foundation002 //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 at006 //007 // http://www.apache.org/licenses/LICENSE-2.0008 //009 // Unless required by applicable law or agreed to in writing, software010 // 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 and013 // limitations under the License.014015 package org.apache.tapestry5.services.ajax;016017 import org.apache.tapestry5.ClientBodyElement;018 import org.apache.tapestry5.services.PartialMarkupRendererFilter;019020 /**021 * Manages the rendering of a partial page render as part of an Ajax response. This replaces022 * the {@link org.apache.tapestry5.ajax.MultiZoneUpdate} introduced in Tapestry 5.1. Much of the API is used to023 * queue behaviors that take effect when {@linkplain org.apache.tapestry5.services.PartialMarkupRenderer partial markup rendering takes place}.024 * <p/>025 * The implementation of this class provides {@link org.apache.tapestry5.services.PartialMarkupRendererFilter} to026 * the {@link org.apache.tapestry5.internal.services.PageRenderQueue}.027 *028 * @since 5.3029 */030 public interface AjaxResponseRenderer031 {032 /**033 * Queues the renderer to render markup for the client-side element with the provided id.034 *035 * @param clientId client id of zone to update with the content from the renderer036 * @param renderer a {@link org.apache.tapestry5.Block}, {@link org.apache.tapestry5.runtime.Component} or other object that can be037 * {@linkplain org.apache.tapestry5.ioc.services.TypeCoercer coerced} to {@link org.apache.tapestry5.runtime.RenderCommand}.038 * @return the renderer, for a fluid interface039 */040 AjaxResponseRenderer addRender(String clientId, Object renderer);041042 /**043 * Queues an update to the zone, using the zone's body as the new content.044 *045 * @param zone the element that contains both a client id and a body (this is primarily used to represent a {@link org.apache.tapestry5.corelib.components.Zone} component).046 * @return this renderer, for a fluid interface047 */048 AjaxResponseRenderer addRender(ClientBodyElement zone);049050 /**051 * Queues a callback to execute during the partial markup render. The callback is {@linkplain #addFilter(org.apache.tapestry5.services.PartialMarkupRendererFilter) added as a filter}; the052 * callback is invoked before the rest of the rendering pipeline is invoked.053 *054 * @param callback object to be invoked055 * @return this renderer, for a fluid interface056 */057 AjaxResponseRenderer addCallback(JavaScriptCallback callback);058059 /**060 * Queues a callback to execute during the partial markup render. . The callback is {@linkplain #addFilter(org.apache.tapestry5.services.PartialMarkupRendererFilter) added as a filter}; the061 * callback is invoked before the rest of the rendering pipeline is invoked.062 *063 * @param callback object to be invoked064 * @return this renderer, for a fluid interface065 */066 AjaxResponseRenderer addCallback(Runnable callback);067068 /**069 * Adds a rendering filter. Dynamically added filters are only in place during the handling of the current request, and come after any filters070 * contributed to the {@link org.apache.tapestry5.services.PartialMarkupRenderer} service.071 *072 * @return this renderer, for a fluid interface073 */074 AjaxResponseRenderer addFilter(PartialMarkupRendererFilter filter);075076 /**077 * Queues a callback to execute during the partial markup render. The callback is {@linkplain #addFilter(org.apache.tapestry5.services.PartialMarkupRendererFilter) added as a filter};078 * the callback is invoked before the rest of the rendering pipeline is invoked.079 *080 * @param callback object o be invoked081 * @return this renderer, for a fluid interface082 */083 AjaxResponseRenderer addCallback(JSONCallback callback);084 }