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