001// Copyright 2006-2013 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
015package org.apache.tapestry5.internal;
016
017import org.apache.tapestry5.dom.MarkupModel;
018import org.apache.tapestry5.ioc.util.TimeInterval;
019import org.apache.tapestry5.services.javascript.JavaScriptStack;
020
021public final class InternalConstants
022{
023    /**
024     * Init parameter used to identify the package from which application classes are loaded. Such
025     * classes are in the
026     * pages, components and mixins sub-packages.
027     */
028    public static final String TAPESTRY_APP_PACKAGE_PARAM = "tapestry.app-package";
029
030    /**
031     * Turns off loading of default modules (as driven by JAR file Manifest entries).
032     */
033    public static final String DISABLE_DEFAULT_MODULES_PARAM = "tapestry.disable-default-modules";
034
035    /**
036     * The name of the query parameter that stores the page activation context inside an action
037     * request.
038     */
039    public static final String PAGE_CONTEXT_NAME = "t:ac";
040
041    /**
042     * Name of event triggered by Grid sub-components when an in-place Grid is updated.
043     */
044    public static final String GRID_INPLACE_UPDATE = "inplaceupdate";
045
046    /**
047     * The name of a query parameter that stores the containing page (used in action links when the
048     * page containing the
049     * component is not the same as the page that was rendering). The active page (the page which
050     * initiated the render)
051     * is encoded into the URL, and the containing page is tacked on as this query parameter.
052     */
053    public static final String CONTAINER_PAGE_NAME = "t:cp";
054
055    public static final String MIXINS_SUBPACKAGE = "mixins";
056
057    public static final String COMPONENTS_SUBPACKAGE = "components";
058
059    public static final String PAGES_SUBPACKAGE = "pages";
060
061    public static final String BASE_SUBPACKAGE = "base";
062
063    /**
064     * Used in some Ajax scenarios to set the content type for the response early, when the Page
065     * instance (the authority
066     * on content types) is known. The value is of type {@link org.apache.tapestry5.ContentType}.
067     */
068    public static final String CONTENT_TYPE_ATTRIBUTE_NAME = "content-type";
069
070    public static final String CHARSET_CONTENT_TYPE_PARAMETER = "charset";
071
072    /**
073     * As above but to store the name of the page. Necessary for determining the correct
074     * {@link MarkupModel} for the response.
075     */
076    public static final String PAGE_NAME_ATTRIBUTE_NAME = "page-name";
077
078    /**
079     * Required MIME type for JSON responses. If this MIME type is not used, the client-side
080     * Prototype code will not
081     * recognize the response as JSON, and the Ajax.Response.responseJSON property will be null.
082     */
083    public static final String JSON_MIME_TYPE = "application/json";
084
085    /**
086     * Request attribute key; if non-null, then automatic GZIP compression of response stream is
087     * suppressed. This is
088     * useful when the code opening the response stream wants to explicitly control whether GZIP
089     * compression occurs or
090     * not.
091     *
092     * @since 5.1.0.0
093     */
094    public static final String SUPPRESS_COMPRESSION = "tapestry.supress-compression";
095
096    /**
097     * Name of response header for content encoding.
098     *
099     * @since 5.1.0.0
100     */
101    public static final String CONTENT_ENCODING_HEADER = "Content-Encoding";
102
103    /**
104     * Response content encoding value indicating use of GZIP compression.
105     *
106     * @since 5.1.0.0
107     */
108    public static final String GZIP_CONTENT_ENCODING = "gzip";
109
110    /**
111     * Identifies the start of an expansion inside a template.
112     */
113    public static final String EXPANSION_START = "${";
114
115    /**
116     * Special prefix for parameters that are inherited from named parameters of their container.
117     */
118    public static final String INHERIT_BINDING_PREFIX = "inherit:";
119
120    public static final long TEN_YEARS = new TimeInterval("10y").milliseconds();
121
122    public static final String[] EMPTY_STRING_ARRAY = new String[0];
123
124    /**
125     * Name of the core {@link JavaScriptStack}, which supplies the basic JavaScript infrastructure
126     * on the client.
127     *
128     * @since 5.2.0
129     */
130    public static final String CORE_STACK_NAME = "core";
131
132    /**
133     * Virtual folder name for the core library. The core library is special as any component not present in another
134     * library (including the application library) is searched for inside core.
135     *
136     * @since 5.3
137     */
138    public static final String CORE_LIBRARY = "core";
139
140    /**
141     * The names of the standard controlled subpackages.
142     *
143     * @since 5.3
144     */
145    public static final String[] SUBPACKAGES =
146            {PAGES_SUBPACKAGE, COMPONENTS_SUBPACKAGE, MIXINS_SUBPACKAGE, BASE_SUBPACKAGE};
147
148    /**
149     * The element name for a submit input element used to cancel the form (rather than
150     * submit it normally).
151     *
152     * @since 5.3
153     */
154    public static final String CANCEL_NAME = "cancel";
155
156    /**
157     * Request attribute that can be set to bypass page activation.
158     *
159     * @see org.apache.tapestry5.internal.services.StreamPageContentResultProcessor
160     * @see org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl
161     * @since 5.4
162     */
163    public static final String BYPASS_ACTIVATION = "tapestry.bypass-page-activation";
164
165    /**
166     * Key inside the response that contains the partial page render keys that are used
167     * to update the client.
168     *
169     * @since 5.4
170     */
171    public static final String PARTIAL_KEY = "_tapestry";
172
173    /**
174     * Request attribute, set to true once the active page (as identified in the incoming
175     * component event or page render request) has been successfully loaded. This is very important
176     * to the {@link org.apache.tapestry5.corelib.pages.ExceptionReport} page, which can possibly
177     * fail (resulting in a servlet container 500 response) if the page can't be loaded (because
178     * if the page can't be loaded, then a link to the page can't be created).
179     *
180     * @since 5.4
181     */
182    public static final String ACTIVE_PAGE_LOADED = "tapestry.active-page-loaded";
183}