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