001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License. 012 013package org.apache.tapestry5.services; 014 015import org.apache.tapestry5.Link; 016import org.apache.tapestry5.services.linktransform.ComponentEventLinkTransformer; 017import org.apache.tapestry5.services.linktransform.PageRenderLinkTransformer; 018 019/** 020 * Responsible for creating {@link org.apache.tapestry5.Link}s for page render requests and for component event 021 * requests, and for parsing incoming paths to identify requests that are component event or page render requests. This 022 * centralizes some logic that was scattered about in Tapestry 5.0. 023 * 024 * @since 5.1.0.1 025 */ 026public interface ComponentEventLinkEncoder 027{ 028 /** 029 * Creates a Link that encapsulates a page render request, including activation context <em>and {@link 030 * org.apache.tapestry5.services.PersistentLocale} (if set)</em>. 031 * Passes the resulting Link through the {@link PageRenderLinkTransformer} chain of command, returning 032 * the result. 033 * 034 * @param parameters 035 * defining page to render and context 036 * @return link for the page render 037 */ 038 Link createPageRenderLink(PageRenderRequestParameters parameters); 039 040 /** 041 * Creates a link that encapsulates a component event request, including <em>{@link 042 * org.apache.tapestry5.services.PersistentLocale} (if set)</em>. 043 * 044 * Forms: 045 * <ul> 046 * <li>/context/pagename:eventname -- event on the page, no action context</li> 047 * <li>/context/pagename:eventname/foo/bar -- event on the page with action context "foo", "bar"</li> 048 * <li>/context/pagename.foo.bar -- event on component foo.bar within the page, default event, no action context</li> 049 * <li>/context/pagename.foo.bar/baz.gnu -- event on component foo.bar within the page, default event, with action 050 * context "baz", "gnu"</li> 051 * <li>/context/pagename.bar.baz:eventname/foo/gnu -- event on component bar.baz within the page with action context 052 * "foo" , "gnu"</li> 053 * </ul> 054 * 055 * The persistent locale may be placed in between the context name and the page name, i.e., "/context/fr/SomePage". 056 * 057 * In many cases the context name is blank, so the path begins with a "/" and then the locale name or page name. 058 * 059 * The page name portion may itself consist of a series of folder names, i.e., "admin/user/create". The context 060 * portion isn't the concern of this code, since {@link org.apache.tapestry5.services.Request#getPath()} will 061 * already have stripped that off. We can act as if the context is always "/" (the path always starts with a slash). 062 * 063 * Passes the resulting Link through the {@link ComponentEventLinkTransformer} chain of command, returning the 064 * result. 065 * 066 * @param parameters 067 * defining page, component, activation context and other details 068 * @param forForm 069 * true if the event link will trigger a form submission 070 * @return link for the component event 071 */ 072 Link createComponentEventLink(ComponentEventRequestParameters parameters, boolean forForm); 073 074 /** 075 * Checks the request, primarily the {@linkplain org.apache.tapestry5.services.Request#getPath() path}, to determine 076 * the if the request is a component event request. As a side-effect (necessary for historical reasons), responsible 077 * for setting the locale for the thread, including the {@link org.apache.tapestry5.services.PersistentLocale} ... 078 * but only if the locale is a component event. 079 * 080 * @param request 081 * incoming request 082 * @return component event request details, if a component event request 083 */ 084 ComponentEventRequestParameters decodeComponentEventRequest(Request request); 085 086 /** 087 * Checks the request, primarily the {@linkplain org.apache.tapestry5.services.Request#getPath() path}, to determine 088 * the if the request is a page render request. As a side-effect (necessary for historical reasons), responsible for 089 * setting the locale for the thread, including the {@link org.apache.tapestry5.services.PersistentLocale} ... but 090 * only if the request is a page render. 091 * 092 * @param request 093 * incoming request 094 * @return page render request details, if a page render request 095 */ 096 PageRenderRequestParameters decodePageRenderRequest(Request request); 097}