View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.shared.config;
20  
21  
22  import javax.faces.context.ExternalContext;
23  import javax.servlet.ServletContext;
24  
25  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
26  import org.apache.myfaces.shared.util.ClassUtils;
27  import org.apache.myfaces.shared.util.WebConfigParamUtils;
28  
29  /**
30   * Holds all configuration init parameters (from web.xml) that are independent
31   * from the core implementation. The parameters in this class are available to
32   * all shared, component and implementation classes.
33   * See RuntimeConfig for configuration infos that come from the faces-config
34   * files and are needed by the core implementation.
35   *
36   * MyfacesConfig is meant for components that implement some of the extended features
37   * of MyFaces. Anyhow, using the MyFaces JSF implementation is no precondition for using
38   * MyfacesConfig in custom components. Upon using another JSF implementation
39   * (or omitting the extended init parameters) all config properties will simply have
40   * their default values.
41   */
42  public class MyfacesConfig
43  {
44      private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
45  
46      /**
47       * Set the virtual path used to serve resources using tomahawk addResource API. Note ExtensionsFilter should
48       * be able to receive request on the prefix used here.
49       */
50      @JSFWebConfigParam(tags="tomahawk")
51      public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH = "org.apache.myfaces.RESOURCE_VIRTUAL_PATH";
52      public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT = "/faces/myFacesExtensionResource";
53  
54      /**
55       * If true, rendered HTML code will be formatted, so that it is "human readable".
56       * i.e. additional line separators and whitespace will be written, that do not
57       * influence the HTML code. Default: "true"
58       */
59      @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1",
60              ignoreUpperLowerCase=true, group="render")
61      private static final String  INIT_PARAM_PRETTY_HTML = "org.apache.myfaces.PRETTY_HTML";
62      private static final boolean INIT_PARAM_PRETTY_HTML_DEFAULT = true;
63  
64      /**
65       * This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output.
66       * If javascript is allowed, command_link anchors will have javascript code 
67       * that submits the corresponding form.
68       * If javascript is not allowed, the state saving info and nested parameters ill be 
69       * added as url parameters.
70       * Default: "true"
71       */
72      @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1",
73              ignoreUpperLowerCase=true, group="render")
74      private static final String  INIT_PARAM_ALLOW_JAVASCRIPT = "org.apache.myfaces.ALLOW_JAVASCRIPT";
75      private static final boolean INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT = true;
76  
77      /**
78       * Deprecated: tomahawk specific param to detect javascript, but it is no longer valid anymore.
79       */
80      @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1",
81              ignoreUpperLowerCase=true, deprecated=true, tags="tomahawk", group="render")
82      private static final String  INIT_PARAM_DETECT_JAVASCRIPT = "org.apache.myfaces.DETECT_JAVASCRIPT";
83      private static final boolean INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT = false;
84  
85      /**
86       * If true, a javascript function will be rendered that is able to restore the 
87       * former vertical scroll on every request. Convenient feature if you have pages
88       * with long lists and you do not want the browser page to always jump to the top
89       * if you trigger a link or button action that stays on the same page.
90       * Default: "false"
91       */
92      @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1", 
93              ignoreUpperLowerCase=true, tags="tomahawk")
94      private static final String  INIT_PARAM_AUTO_SCROLL = "org.apache.myfaces.AUTO_SCROLL";
95      private static final boolean INIT_PARAM_AUTO_SCROLL_DEFAULT = false;
96  
97      /**
98       * Tomahawk specific: A class implementing the
99       * org.apache.myfaces.shared.renderkit.html.util.AddResource
100      * interface. It is responsible to
101      * place scripts and css on the right position in your HTML document.
102      * Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"
103      * Follow the description on the MyFaces-Wiki-Performance page to enable
104      * StreamingAddResource instead of DefaultAddResource if you want to
105      * gain performance.
106      */
107     @JSFWebConfigParam(defaultValue="org.apache.myfaces. renderkit.html.util. DefaultAddResource",since="1.1",
108             desc="Tomahawk specific: Indicate the class responsible to place scripts and css using " +
109                  "tomahawk AddResource API", tags="tomahawk")
110     private static final String INIT_PARAM_ADD_RESOURCE_CLASS = "org.apache.myfaces.ADD_RESOURCE_CLASS";
111     private static final String INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT = 
112         "org.apache.myfaces.renderkit.html.util.DefaultAddResource";
113 
114     /**
115      * Tomahawk specific: A very common problem in configuring MyFaces-web-applications
116      * is that the Extensions-Filter is not configured at all
117      * or improperly configured. This parameter will check for a properly
118      * configured Extensions-Filter if it is needed by the web-app.
119      * In most cases this check will work just fine, there might be cases
120      * where an internal forward will bypass the Extensions-Filter and the check
121      * will not work. If this is the case, you can disable the check by setting
122      * this parameter to false.
123      * 
124      * In tomahawk for JSF 2.0 since version 1.1.11, this param is set by default to false, otherwise is true.
125      */
126     @JSFWebConfigParam(defaultValue="for JSF 2.0 since 1.1.11 false, otherwise true", 
127             expectedValues="true, false, on, off, yes, no",since="1.1", ignoreUpperLowerCase=true,
128             desc="Tomahawk specific: This parameter will check for a properly configured Extensions-Filter if " +
129                  "it is needed by the web-app.", tags="tomahawk")
130     private static final String  INIT_CHECK_EXTENSIONS_FILTER = "org.apache.myfaces.CHECK_EXTENSIONS_FILTER";
131     private static final boolean INIT_CHECK_EXTENSIONS_FILTER_DEFAULT = false;
132 
133     /**
134      * Tomahawk specific: Interpret "readonly" property as "disable" for select components like t:selectOneRow.
135      */
136     @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1", 
137             ignoreUpperLowerCase=true, tags="tomahawk", group="render")
138     private static final String INIT_READONLY_AS_DISABLED_FOR_SELECT = 
139         "org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS";
140     private static final boolean INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT = true;
141 
142     /**
143      * Set the time in seconds that check for updates of web.xml and faces-config descriptors and 
144      * refresh the configuration.
145      * This param is valid only if project stage is not production. Set this param to 0 disable this feature.
146      */
147     @JSFWebConfigParam(defaultValue="2",since="1.1", classType="java.lang.Long")
148     public static final String INIT_PARAM_CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
149     public static final long INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT = 2;
150 
151     /**
152      * Set the view state using a javascript function instead a hidden input field.
153      */
154     @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1", 
155             ignoreUpperLowerCase=true, deprecated=true, group="state")
156     private static final String  INIT_PARAM_VIEWSTATE_JAVASCRIPT = "org.apache.myfaces.VIEWSTATE_JAVASCRIPT";
157     private static final boolean INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT = false;
158 
159     /**
160      * Define if the input field that should store the state (javax.faces.ViewState) should render 
161      * id="javax.faces.ViewState".
162      * 
163      * JSF API 1.2 defines a "javax.faces.ViewState" client parameter, that must be rendered as both the "name"
164      * and the "id" attribute of the hidden input that is rendered for the purpose of state saving
165      * (see ResponseStateManager.VIEW_STATE_PARAM).
166      * Actually this causes duplicate id attributes and thus invalid XHTML pages when multiple forms are rendered on
167      * one page. With the org.apache.myfaces.RENDER_VIEWSTATE_ID context parameter you can tune this behaviour.
168      * <br/>Set it to
169      * <ul><li>true - to render JSF 1.2 compliant id attributes (that might cause invalid XHTML), or</li>
170      * <li>false - to omit rendering of the id attribute (which is only needed for very special 
171      * AJAX/Javascript components)</li></ul>
172      * Default value is: true (for backwards compatibility and JSF 1.2 compliancy) 
173      */
174     @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1", 
175             ignoreUpperLowerCase=true, group="state")
176     private static final String  INIT_PARAM_RENDER_VIEWSTATE_ID = "org.apache.myfaces.RENDER_VIEWSTATE_ID";
177     private static final boolean INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT = true;
178 
179     /**
180      * Use "&amp;amp;" entity instead a plain "&amp;" character within HTML.
181      * <p>W3C recommends to use the "&amp;amp;" entity instead of a plain "&amp;" character within HTML.
182      * This also applies to attribute values and thus to the "href" attribute of &lt;a&gt; elements as well.
183      * Even more, when XHTML is used as output the usage of plain "&amp;" characters is forbidden and would lead to
184      * invalid XML code.
185      * Therefore, since version 1.1.6 MyFaces renders the correct "&amp;amp;" entity for links.</p>
186      * <p>The init parameter
187      * org.apache.myfaces.STRICT_XHTML_LINKS makes it possible to restore the old behaviour and to make MyFaces
188      * "bug compatible" to the Sun RI which renders plain "&amp;" chars in links as well.</p>
189      * <p>
190      * See: <a href="http://www.w3.org/TR/html401/charset.html#h-5.3.2">HTML 4.01 Specification</a>
191      * See: <a href="http://issues.apache.org/jira/browse/MYFACES-1774">Jira: MYFACES-1774</a>
192      * </p>
193      */
194     @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1.6", 
195             ignoreUpperLowerCase=true, group="render")
196     private static final String  INIT_PARAM_STRICT_XHTML_LINKS = "org.apache.myfaces.STRICT_XHTML_LINKS";
197     private static final boolean INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT = true;
198     
199     /**
200      * This param renders the clear javascript on button necessary only for
201      * compatibility with hidden fields feature of myfaces. This is done 
202      * because jsf ri does not render javascript on onclick method for button,
203      * so myfaces should do this.
204      */
205     @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.2.3",
206             ignoreUpperLowerCase=true, group="render")
207     private static final String INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON = 
208         "org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON";
209     private static final boolean INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT= false;
210 
211     /**
212      * This param renders hidden fields at the end of h:form for link params when h:commandLink + f:param is used,
213      * instead use javascript to create them. Set this param to true also enables 
214      * org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON 
215      * automatically to ensure consistency. This feature is required to support Windows Mobile 6, because in 
216      * this environment, document.createElement() and form.appendChild() javascript methods are not supported.
217      */
218     @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.2.9",
219             ignoreUpperLowerCase=true, group="render")
220     private static final String INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS = 
221         "org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS";
222     private static final boolean INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT= false;
223     
224     /**
225      * Add a code that save the form before submit using a
226      * link (call to window.external.AutoCompleteSaveForm(form) ). It's a bug on IE.
227      */
228     @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1",
229             ignoreUpperLowerCase=true, group="render")
230     private static final String INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE = "org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE";
231     private static final boolean INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT = false;
232     
233     /**
234      * Define an alternate class name that will be used to initialize MyFaces, instead the default 
235      * javax.faces.webapp.FacesServlet.
236      * 
237      * <p>This helps MyFaces to detect the mappings and other additional configuration used to setup the 
238      * environment, and prevent abort initialization if no FacesServlet config is detected.
239      * </p>
240      */
241     @JSFWebConfigParam(since="1.2.7")
242     private static final String INIT_PARAM_DELEGATE_FACES_SERVLET = "org.apache.myfaces.DELEGATE_FACES_SERVLET";
243 
244     /**
245      * Indicate if the facelet associated to the view should be reapplied when the view is refreshed.
246      *  Default mode is "auto".
247      * 
248      * <p>This param is only valid when partial state saving is on.
249      * If this is set as true, the tag-handlers are always reapplied before render view, like in facelets 1.1.x, 
250      * allowing c:if work correctly to "toggle" components based on a value changed on invoke application phase. 
251      * If the param is set as "auto", the implementation check if c:if, c:forEach, 
252      * c:choose and ui:include with src=ELExpression is used on the page and if that so, mark the view
253      * to be refreshed.</p> 
254      */
255     @JSFWebConfigParam(since="2.0", defaultValue="auto", expectedValues="true,false,auto", tags="performance", 
256             ignoreUpperLowerCase=true, group="state")
257     public final static String INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS = 
258         "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS"; 
259     public final static String INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT = "auto";
260 
261     /**
262      * Enable or disable a special mode that enable full state for parent components containing c:if, c:forEach, 
263      * c:choose and ui:include with src=ELExpression. By default is disabled(false).
264      * 
265      * <p>This param is only valid when partial state saving is on.
266      * If this is set as true, parent components containing  c:if, c:forEach, 
267      * c:choose and ui:include with src=ELExpression are marked to be restored fully, so state
268      * is preserved between request.</p>
269      */
270     @JSFWebConfigParam(since="2.0", defaultValue="false", expectedValues="true, false, on, off, yes, no", 
271             tags="performance", ignoreUpperLowerCase=true, group="state")
272     public final static String INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE = 
273         "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE";
274     public final static boolean INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT = false;
275     
276     /**
277      * If set to <code>true</code>, tag library XML files and faces config XML files using schema 
278      * will be validated during application start up
279      */
280     @JSFWebConfigParam(since="2.0", expectedValues="true, false, on, off, yes, no", ignoreUpperLowerCase=true)
281     public final static String INIT_PARAM_VALIDATE_XML = "org.apache.myfaces.VALIDATE_XML";
282     public final static boolean INIT_PARAM_VALIDATE_XML_DEFAULT = false;
283     
284     /**
285      * Wrap content inside script with xml comment to prevent old browsers to display it. By default it is true. 
286      */
287     @JSFWebConfigParam(since="2.0.1", expectedValues="true, false, on, off, yes, no", defaultValue="false",
288             ignoreUpperLowerCase=true, group="render")
289     public final static String INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG = 
290         "org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG";
291     public final static boolean INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT = false;
292     
293     /**
294      * If set true, render the form submit script inline, as in myfaces core 1.2 and earlier versions 
295      */
296     @JSFWebConfigParam(since="2.0.2", expectedValues="true, false, on, off, yes, no", defaultValue="false", 
297             ignoreUpperLowerCase=true, group="render")
298     public final static String INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE = 
299         "org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE";
300     public final static boolean INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT = false;
301     
302     /**
303      * Enable/disable DebugPhaseListener feature, with provide useful information about ValueHolder 
304      * variables (submittedValue, localValue, value).
305      * Note evaluate those getters for each component could cause some unwanted side effects when 
306      * using "access" type scopes like on MyFaces CODI.
307      * This param only has effect when project stage is Development.     
308      */
309     @JSFWebConfigParam(since="2.0.8")
310     public final static String INIT_PARAM_DEBUG_PHASE_LISTENER = "org.apache.myfaces.DEBUG_PHASE_LISTENER";
311     public final static boolean INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT = false;
312     
313     /**
314      * Detect if a target (usually head) should be update for the current view in an ajax render 
315      * operation. This is activated if a css or js resource is added dynamically by effect of a refresh 
316      * (c:if, ui:include src="#{...}" or a manipulation of the tree). This ensures ajax updates of content 
317      * using ui:include will be consistent. Note this behavior is a myfaces specific extension, so to 
318      * ensure strict compatibility with the spec, set this param to false (default false).
319      */
320     @JSFWebConfigParam(since="2.0.10", expectedValues="true, false", defaultValue="false")
321     public final static String INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX = 
322         "org.apache.myfaces.STRICT_JSF_2_REFRESH_TARGET_AJAX";
323     public final static boolean INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT = false;
324     
325     /**
326      * Change default getType() behavior for composite component EL resolver, from return null 
327      * (see JSF 2_0 spec section 5_6_2_2) to
328      * use the metadata information added by composite:attribute, ensuring components working with 
329      * chained EL expressions to find the
330      * right type when a getType() is called over the source EL expression.
331      * 
332      * To ensure strict compatibility with the spec set this param to true (by default is false, 
333      * so the change is enabled by default). 
334      */
335     @JSFWebConfigParam(since="2.0.10", expectedValues="true, false", defaultValue="false", group="EL")
336     public final static String INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER = 
337         "org.apache.myfaces.STRICT_JSF_2_CC_EL_RESOLVER";
338     public final static boolean INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT = false;
339     
340     /**
341      * Define the default content type that the default ResponseWriter generates, when no match can be derived from
342      * HTTP Accept Header.
343      */
344     @JSFWebConfigParam(since="2.0.11,2.1.5", expectedValues="text/html, application/xhtml+xml", 
345             defaultValue="text/html", group="render")
346     public final static String INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE = 
347         "org.apache.myfaces.DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE";
348     public final static String INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT = "text/html";
349 
350     /**
351      * Enable or disable a cache used to "remember" the generated facelets unique ids and reduce 
352      * the impact on memory usage, only active if javax.faces.FACELETS_REFRESH_PERIOD is -1 (no refresh).
353      */
354     @JSFWebConfigParam(defaultValue = "true", since = "2.0.13, 2.1.7", expectedValues="true, false", 
355             group="viewhandler", tags="performance",
356             desc="Enable or disable a cache used to 'remember'  the generated facelets unique ids " + 
357                  "and reduce the impact over memory usage.")
358     public static final String INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED = 
359         "org.apache.myfaces.VIEW_UNIQUE_IDS_CACHE_ENABLED";
360     public static final boolean INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT = true;
361     
362     /**
363      * Set the size of the cache used to store strings generated using SectionUniqueIdCounter
364      * for component ids. If this is set to 0, no cache is used. By default is set to 100.
365      */
366     @JSFWebConfigParam(defaultValue = "100", since = "2.0.13, 2.1.7",
367             group="viewhandler", tags="performance")
368     public static final String INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE =
369         "org.apache.myfaces.COMPONENT_UNIQUE_IDS_CACHE_SIZE";
370     public static final int INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT = 100;
371 
372     /**
373     * If set false, myfaces won't support JSP and javax.faces.el. JSP are deprecated in JSF 2.X, javax.faces.el in 
374     * in JSF 1.2. Default value is true. 
375     * 
376     * If this property is set is false, JSF 1.1 VariableResolver and PropertyResolver config (replaced in JSF 1.2 by
377     * ELResolver) and all related logic for JSP is skipped, making EL evaluation faster.  
378     */
379     @JSFWebConfigParam(since="2.0.13,2.1.7", expectedValues="true,false", defaultValue="true",
380          desc="If set false, myfaces won't support JSP and javax.faces.el. JSP are deprecated in " +
381          "JSF 2.X, javax.faces.el in in JSF 1.2. Default value is true.",
382          group="EL", tags="performance ")
383     public final static String INIT_PARAM_SUPPORT_JSP_AND_FACES_EL = "org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL";
384     public final static boolean INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT = true;
385     
386     /**
387      * When the application runs inside Google Application Engine container (GAE),
388      * indicate which jar files should be scanned for files (faces-config, facelets taglib
389      * or annotations). It accept simple wildcard patterns like myfavoritejsflib-*.jar or 
390      * myfavoritejsflib-1.1.?.jar. By default, all the classpath is scanned for files 
391      * annotations (so it adds an small delay on startup).
392      */
393     @JSFWebConfigParam(since = "2.1.8, 2.0.14", expectedValues="none, myfavoritejsflib-*.jar",
394             tags="performance, GAE")
395     public static final String INIT_PARAM_GAE_JSF_JAR_FILES = "org.apache.myfaces.GAE_JSF_JAR_FILES";
396     public final static String INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT = null;
397 
398     /**
399      * When the application runs inside Google Application Engine container (GAE),
400      * indicate which jar files should be scanned for annotations. This param overrides
401      * org.apache.myfaces.GAE_JSF_JAR_FILES behavior that tries to find faces-config.xml or
402      * files ending with .faces-config.xml in /META-INF folder and if that so, try to
403      * find JSF annotations in the whole jar file. It accept simple wildcard patterns 
404      * like myfavoritejsflib-*.jar or myfavoritejsflib-1.1.?.jar.
405      * By default, all the classpath is scanned for annotations (so it adds an small
406      * delay on startup).
407      */
408     @JSFWebConfigParam(since = "2.1.8, 2.0.14", expectedValues="none, myfavoritejsflib-*.jar",
409             tags="performance, GAE")
410     public static final String INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES = 
411             "org.apache.myfaces.GAE_JSF_ANNOTATIONS_JAR_FILES";
412     public final static String INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT = null;
413     
414     /**
415      * If this param is set to true, a check will be done in Restore View Phase to check
416      * if the viewId exists or not and if it does not exists, a 404 response will be thrown.
417      * 
418      * This is applicable in cases where all the views in the application are generated by a 
419      * ViewDeclarationLanguage implementation.
420      */
421     @JSFWebConfigParam(since = "2.1.13", defaultValue="false", expectedValues="true,false", 
422             group="viewhandler")
423     public static final String INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND = 
424             "org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND";
425     public final static boolean INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT = false;
426 
427     @JSFWebConfigParam(defaultValue = "false", since = "2.2.0", expectedValues="true, false", group="render",
428             tags="performance",
429             desc="Enable or disable an early flush which allows to send e.g. the HTML-Head to the client " +
430                     "while the rest gets rendered. It's a well known technique to reduce the time for loading a page.")
431     private static final String INIT_PARAM_EARLY_FLUSH_ENABLED =
432         "org.apache.myfaces.EARLY_FLUSH_ENABLED";
433     private static final boolean INIT_PARAM_EARLY_FLUSH_ENABLED_DEFAULT = false;
434 
435     @JSFWebConfigParam(defaultValue = "false", since = "2.2.0", expectedValues="true, false", group="cdi",
436             tags="injection",
437             desc="Enable or disable CDI support for converters.")
438     private static final String INIT_PARAM_CDI_MANAGED_CONVERTERS_ENABLED =
439         "org.apache.myfaces.CDI_MANAGED_CONVERTERS_ENABLED";
440     private static final boolean INIT_PARAM_CDI_MANAGED_CONVERTERS_DEFAULT = false;
441     @JSFWebConfigParam(defaultValue = "false", since = "2.2.0", expectedValues="true, false", group="cdi",
442             tags="injection",
443             desc="Enable or disable CDI support for validators.")
444     private static final String INIT_PARAM_CDI_MANAGED_VALIDATORS_ENABLED =
445         "org.apache.myfaces.CDI_MANAGED_VALIDATORS_ENABLED";
446     private static final boolean INIT_PARAM_CDI_MANAGED_VALIDATORS_DEFAULT = false;
447     
448     /**
449      * This param makes components like c:set, ui:param and templating components like ui:decorate,
450      * ui:composition and ui:include to behave like the ones provided originally in facelets 1_1_x. 
451      * See MYFACES-3810 for details.
452      */
453     @JSFWebConfigParam(since = "2.2.0", defaultValue="false", expectedValues="true,false", 
454             group="viewhandler")
455     public static final String INIT_PARAM_STRICT_JSF_2_FACELETS_COMPATIBILITY = 
456             "org.apache.myfaces.STRICT_JSF_2_FACELETS_COMPATIBILITY";
457     public final static boolean INIT_PARAM_STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT = false;    
458 
459     private boolean _prettyHtml;
460     private boolean _detectJavascript;
461     private boolean _allowJavascript;
462     private boolean _autoScroll;
463     private String _addResourceClass;
464     private String _resourceVirtualPath;
465     private boolean _checkExtensionsFilter;
466     private boolean _readonlyAsDisabledForSelect;
467     private long _configRefreshPeriod;
468     private boolean _viewStateJavascript;
469     private boolean _renderViewStateId;
470     private boolean _strictXhtmlLinks;
471     private boolean _renderClearJavascriptOnButton;
472     private boolean renderHiddenFieldsForLinkParams;
473     private boolean _saveFormSubmitLinkIE;
474     private String _delegateFacesServlet;
475     private boolean _refreshTransientBuildOnPSS;
476     private boolean _refreshTransientBuildOnPSSAuto;
477     private boolean refreshTransientBuildOnPSSPreserveState;
478     private boolean _validateXML;
479     private boolean _wrapScriptContentWithXmlCommentTag;
480     private boolean _renderFormSubmitScriptInline;
481     private boolean _debugPhaseListenerEnabled;
482     private boolean _strictJsf2RefreshTargetAjax;
483     private boolean _strictJsf2CCELResolver;
484     private String _defaultResponseWriterContentTypeMode;
485     private boolean _viewUniqueIdsCacheEnabled;
486     private int _componentUniqueIdsCacheSize;
487     private boolean _supportJSPAndFacesEL;
488     private String _gaeJsfJarFiles;
489     private String _gaeJsfAnnotationsJarFiles;
490     private boolean _strictJsf2ViewNotFound;
491     private boolean _earlyFlushEnabled;
492     private boolean _cdiManagedConvertersEnabled;
493     private boolean _cdiManagedValidatorsEnabled;
494     private boolean _strictJsf2FaceletsCompatibility;
495 
496     private static final boolean TOMAHAWK_AVAILABLE;
497     private static final boolean MYFACES_IMPL_AVAILABLE;
498     private static final boolean RI_IMPL_AVAILABLE;
499 
500     static
501     {
502         boolean tomahawkAvailable;
503         try
504         {
505             ClassUtils.classForName("org.apache.myfaces.webapp.filter.ExtensionsFilter");
506             tomahawkAvailable = true;
507         }
508         catch (ClassNotFoundException e)
509         {
510             tomahawkAvailable = false;
511         }
512         TOMAHAWK_AVAILABLE = tomahawkAvailable;
513     }
514 
515     static
516     {
517         boolean myfacesImplAvailable;
518         try
519         {
520             ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
521             myfacesImplAvailable = true;
522         }
523         catch (ClassNotFoundException e)
524         {
525             myfacesImplAvailable = false;
526         }
527         MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
528     }
529 
530     static
531     {
532         boolean riImplAvailable;
533         try
534         {
535             ClassUtils.classForName("com.sun.faces.application.ApplicationImpl");
536             riImplAvailable = true;
537         }
538         catch (ClassNotFoundException e)
539         {
540             riImplAvailable = false;
541         }
542         RI_IMPL_AVAILABLE = riImplAvailable;
543     }
544 
545     public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
546     {
547         MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx
548                 .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
549         if (myfacesConfig == null)
550         {
551 
552             myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
553 
554             extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
555 
556         }
557 
558         return myfacesConfig;
559     }
560     
561     public MyfacesConfig()
562     {
563         setPrettyHtml(INIT_PARAM_PRETTY_HTML_DEFAULT);
564         setAllowJavascript(INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT);
565         setRenderClearJavascriptOnButton(INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT);
566         setRenderHiddenFieldsForLinkParams(INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT);
567         setSaveFormSubmitLinkIE(INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT);
568         setReadonlyAsDisabledForSelect(INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT);
569         setRenderViewStateId(INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT);
570         setStrictXhtmlLinks(INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT);
571         setConfigRefreshPeriod(INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT);        
572         setViewStateJavascript(INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT);        
573         setRefreshTransientBuildOnPSS(true);
574         setRefreshTransientBuildOnPSSAuto(true);
575         setRefreshTransientBuildOnPSSPreserveState(INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT);
576         setValidateXML(INIT_PARAM_VALIDATE_XML_DEFAULT);
577         setWrapScriptContentWithXmlCommentTag(INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT);
578         setDetectJavascript(INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT);
579         setAutoScroll(INIT_PARAM_AUTO_SCROLL_DEFAULT);
580         setAddResourceClass(INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT);
581         setResourceVirtualPath(INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT);
582         //The default is true but we'll let it false because it depends if 
583         //tomahawk is on classpath and no test environment is set
584         setCheckExtensionsFilter(false);
585         setRenderFormSubmitScriptInline(INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT);
586         setDebugPhaseListenerEnabled(INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT);
587         setStrictJsf2RefreshTargetAjax(INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT);
588         setStrictJsf2CCELResolver(INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT);
589         setDefaultResponseWriterContentTypeMode(INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT);
590         setViewUniqueIdsCacheEnabled(INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT);
591         setComponentUniqueIdsCacheSize(INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT);
592         setSupportJSPAndFacesEL(INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT);
593         setGaeJsfJarFiles(INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT);
594         setGaeJsfAnnotationsJarFiles(INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT);
595         setStrictJsf2ViewNotFound(INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT);
596         setEarlyFlushEnabled(INIT_PARAM_EARLY_FLUSH_ENABLED_DEFAULT);
597         setCdiManagedConvertersEnabled(INIT_PARAM_CDI_MANAGED_CONVERTERS_DEFAULT);
598         setCdiManagedValidatorsEnabled(INIT_PARAM_CDI_MANAGED_VALIDATORS_DEFAULT);
599         setStrictJsf2FaceletsCompatibility(INIT_PARAM_STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT);
600     }
601 
602     private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx)
603     {
604         
605         MyfacesConfig myfacesConfig = new MyfacesConfig();
606 
607         myfacesConfig.setPrettyHtml(getBooleanInitParameter(extCtx, INIT_PARAM_PRETTY_HTML,
608                                                             INIT_PARAM_PRETTY_HTML_DEFAULT));
609         myfacesConfig.setAllowJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_ALLOW_JAVASCRIPT,
610                                                                  INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT));
611 
612         myfacesConfig.setRenderClearJavascriptOnButton(getBooleanInitParameter(extCtx, 
613                                                             INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON,
614                                                             INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT));
615 
616         myfacesConfig.setRenderHiddenFieldsForLinkParams(getBooleanInitParameter(extCtx, 
617                 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS,
618                 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT));
619 
620         myfacesConfig.setSaveFormSubmitLinkIE(getBooleanInitParameter(extCtx, INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE,
621                                                             INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT));
622         
623         myfacesConfig.setReadonlyAsDisabledForSelect(getBooleanInitParameter(extCtx, 
624                                                                  INIT_READONLY_AS_DISABLED_FOR_SELECT,
625                                                                  INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT));
626         myfacesConfig.setRenderViewStateId(getBooleanInitParameter(extCtx, INIT_PARAM_RENDER_VIEWSTATE_ID,
627                                                                    INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT));
628         myfacesConfig.setStrictXhtmlLinks(getBooleanInitParameter(extCtx, INIT_PARAM_STRICT_XHTML_LINKS,
629                                                                   INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT));
630         myfacesConfig.setRenderFormSubmitScriptInline(getBooleanInitParameter(extCtx,
631                                                                   INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE,
632                                                                   INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT));
633         
634         myfacesConfig.setConfigRefreshPeriod(getLongInitParameter(extCtx, INIT_PARAM_CONFIG_REFRESH_PERIOD,
635                 INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT));
636 
637         myfacesConfig.setViewStateJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_VIEWSTATE_JAVASCRIPT,
638                 INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT));
639 
640         myfacesConfig.setDelegateFacesServlet(extCtx.getInitParameter(INIT_PARAM_DELEGATE_FACES_SERVLET));
641         
642         String refreshTransientBuildOnPSS = getStringInitParameter(extCtx, 
643                 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, 
644                 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT);
645         
646         if (refreshTransientBuildOnPSS == null)
647         {
648             myfacesConfig.setRefreshTransientBuildOnPSS(false);
649             myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
650         }
651         else if ("auto".equalsIgnoreCase(refreshTransientBuildOnPSS))
652         {
653             myfacesConfig.setRefreshTransientBuildOnPSS(true);
654             myfacesConfig.setRefreshTransientBuildOnPSSAuto(true);
655         }
656         else if (refreshTransientBuildOnPSS.equalsIgnoreCase("true") || 
657                 refreshTransientBuildOnPSS.equalsIgnoreCase("on") || 
658                 refreshTransientBuildOnPSS.equalsIgnoreCase("yes"))
659         {
660             myfacesConfig.setRefreshTransientBuildOnPSS(true);
661             myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
662         }
663         else
664         {
665             myfacesConfig.setRefreshTransientBuildOnPSS(false);
666             myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
667         }
668         
669         myfacesConfig.setRefreshTransientBuildOnPSSPreserveState(getBooleanInitParameter(extCtx,
670                 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE, 
671                 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT));
672         
673         myfacesConfig.setValidateXML(getBooleanInitParameter(extCtx, INIT_PARAM_VALIDATE_XML, 
674                 INIT_PARAM_VALIDATE_XML_DEFAULT));
675         
676         myfacesConfig.setWrapScriptContentWithXmlCommentTag(getBooleanInitParameter(extCtx, 
677                 INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG, 
678                 INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT));
679         
680         myfacesConfig.setDebugPhaseListenerEnabled(getBooleanInitParameter(extCtx, INIT_PARAM_DEBUG_PHASE_LISTENER,
681                 INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT));
682         
683         myfacesConfig.setStrictJsf2RefreshTargetAjax(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
684                 INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX, INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT));
685         
686         myfacesConfig.setStrictJsf2CCELResolver(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
687                 INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER, INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT));
688         
689         myfacesConfig.setDefaultResponseWriterContentTypeMode(WebConfigParamUtils.getStringInitParameter(
690                 extCtx, INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE,
691                 INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT));
692 
693         myfacesConfig.setViewUniqueIdsCacheEnabled(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
694                 INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED, INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT));
695         myfacesConfig.setComponentUniqueIdsCacheSize(
696                 WebConfigParamUtils.getIntegerInitParameter(extCtx,
697                 INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE, 
698                 INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT));
699         myfacesConfig.setSupportJSPAndFacesEL(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
700                 INIT_PARAM_SUPPORT_JSP_AND_FACES_EL, INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT));
701         
702         myfacesConfig.setGaeJsfJarFiles(WebConfigParamUtils.getStringInitParameter(extCtx, 
703                 INIT_PARAM_GAE_JSF_JAR_FILES, INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT));
704         myfacesConfig.setGaeJsfAnnotationsJarFiles(WebConfigParamUtils.getStringInitParameter(extCtx, 
705                 INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES, INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT));
706 
707         myfacesConfig.setStrictJsf2ViewNotFound(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
708                 INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND, INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT));
709         
710         myfacesConfig.setEarlyFlushEnabled(WebConfigParamUtils.getBooleanInitParameter(extCtx,
711                 INIT_PARAM_EARLY_FLUSH_ENABLED, INIT_PARAM_EARLY_FLUSH_ENABLED_DEFAULT));
712 
713         myfacesConfig.setCdiManagedConvertersEnabled(WebConfigParamUtils.getBooleanInitParameter(extCtx,
714                 INIT_PARAM_CDI_MANAGED_CONVERTERS_ENABLED, INIT_PARAM_CDI_MANAGED_CONVERTERS_DEFAULT));
715         myfacesConfig.setCdiManagedValidatorsEnabled(WebConfigParamUtils.getBooleanInitParameter(extCtx,
716                 INIT_PARAM_CDI_MANAGED_VALIDATORS_ENABLED, INIT_PARAM_CDI_MANAGED_VALIDATORS_DEFAULT));
717 
718         myfacesConfig.setStrictJsf2FaceletsCompatibility(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
719                 INIT_PARAM_STRICT_JSF_2_FACELETS_COMPATIBILITY, 
720                 INIT_PARAM_STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT));
721         
722         if (TOMAHAWK_AVAILABLE)
723         {
724             myfacesConfig.setDetectJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_DETECT_JAVASCRIPT,
725                     INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT));
726             myfacesConfig.setAutoScroll(getBooleanInitParameter(extCtx, INIT_PARAM_AUTO_SCROLL,
727                     INIT_PARAM_AUTO_SCROLL_DEFAULT));
728                         
729             myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
730                     INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
731             myfacesConfig.setResourceVirtualPath(getStringInitParameter(extCtx, INIT_PARAM_RESOURCE_VIRTUAL_PATH,
732                     INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT));
733 
734             myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
735                     INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
736             /*
737             if(RI_IMPL_AVAILABLE)
738             {
739                 if(log.isLoggable(Level.INFO))
740                 {
741                     log.info("Starting up Tomahawk on the RI-JSF-Implementation.");
742                 }
743             }
744 
745             if(MYFACES_IMPL_AVAILABLE)
746             {
747                 if(log.isLoggable(Level.INFO))
748                 {
749                     log.info("Starting up Tomahawk on the MyFaces-JSF-Implementation");
750                 }
751             }*/
752         }
753         /*
754         else
755         {
756             if (log.isLoggable(Level.INFO))
757             {
758                 log.info("Tomahawk jar not available. Autoscrolling, DetectJavascript, "+
759                 "AddResourceClass and CheckExtensionsFilter are disabled now.");
760             }
761         }*/
762 
763         /*
764         if(RI_IMPL_AVAILABLE && MYFACES_IMPL_AVAILABLE)
765         {
766             log.severe("Both MyFaces and the RI are on your classpath. Please make sure to"+
767             " use only one of the two JSF-implementations.");
768         }*/
769         return myfacesConfig;
770     }
771 
772     private static boolean getBooleanInitParameter(ExternalContext externalContext,
773                                                    String paramName,
774                                                    boolean defaultValue)
775     {
776         String strValue = externalContext.getInitParameter(paramName);
777         if (strValue == null)
778         {
779             //if (log.isLoggable(Level.INFO)) log.info("No context init parameter '" + 
780             // paramName + "' found, using default value " + defaultValue);
781             return defaultValue;
782         }
783         else if (strValue.equalsIgnoreCase("true") || strValue.equalsIgnoreCase("on") || 
784                 strValue.equalsIgnoreCase("yes"))
785         {
786             return true;
787         }
788         else if (strValue.equalsIgnoreCase("false") || strValue.equalsIgnoreCase("off") || 
789                 strValue.equalsIgnoreCase("no"))
790         {
791             return false;
792         }
793         else
794         {
795             //if (log.isLoggable(Level.WARNING)) log.warning("Wrong context init parameter '" + 
796             //paramName + "' (='" + strValue + "'), using default value " + defaultValue);
797             return defaultValue;
798         }
799     }
800 
801     private static String getStringInitParameter(ExternalContext externalContext,
802                                                  String paramName,
803                                                  String defaultValue)
804     {
805         String strValue = externalContext.getInitParameter(paramName);
806         if (strValue == null)
807         {
808             //if (log.isLoggable(Level.INFO)) log.info("No context init parameter '" + paramName +
809             //"' found, using default value " + defaultValue); //defaultValue==null should not be 
810             //a problem here
811             return defaultValue;
812         }
813         
814         return strValue;
815     }
816 
817     private static long getLongInitParameter(ExternalContext externalContext,
818                                                   String paramName,
819                                                   long defaultValue)
820     {
821        String strValue = externalContext.getInitParameter(paramName);
822        if (strValue == null)
823        {
824            //if (log.isLoggable(Level.INFO)) log.info("No context init parameter '" +paramName +
825            //"' found, using default value " +defaultValue);
826            return defaultValue;
827        }
828        else
829        {
830            try
831            {
832                return Long.parseLong(strValue);
833            }
834            catch (NumberFormatException e)
835            {
836                //if (log.isLoggable(Level.WARNING)) log.warning("Wrong context init parameter '" +
837                //paramName + "' (='" + strValue + "'), using default value " + defaultValue);
838            }
839            return defaultValue;
840        }
841     }
842         
843      private void setResourceVirtualPath( String resourceVirtualPath )
844      {
845          this._resourceVirtualPath = resourceVirtualPath;
846     }
847 
848      public String getResourceVirtualPath()
849      {
850          return this._resourceVirtualPath;
851      }
852 
853     public boolean isPrettyHtml()
854     {
855         return _prettyHtml;
856     }
857 
858     private void setPrettyHtml(boolean prettyHtml)
859     {
860         _prettyHtml = prettyHtml;
861     }
862 
863     public boolean isDetectJavascript()
864     {
865         return _detectJavascript;
866     }
867 
868     private void setDetectJavascript(boolean detectJavascript)
869     {
870         _detectJavascript = detectJavascript;
871     }
872 
873     private void setReadonlyAsDisabledForSelect(boolean readonlyAsDisabledForSelect)
874     {
875         _readonlyAsDisabledForSelect = readonlyAsDisabledForSelect;
876     }
877 
878     public boolean isReadonlyAsDisabledForSelect()
879     {
880         return _readonlyAsDisabledForSelect;
881     }
882 
883 
884    public long getConfigRefreshPeriod()
885    {
886        return _configRefreshPeriod;
887    }
888 
889    public void setConfigRefreshPeriod(long configRefreshPeriod)
890    {
891        _configRefreshPeriod = configRefreshPeriod;
892    }
893 
894     /**
895      * JSF API 1.2 defines a "javax.faces.ViewState" client parameter, that must be rendered as both the "name"
896      * and the "id" attribute of the hidden input that is rendered for the purpose of state saving
897      * (see ResponseStateManager.VIEW_STATE_PARAM).
898      * Actually this causes duplicate id attributes and thus invalid XHTML pages when multiple forms are rendered on
899      * one page. With the {@link #INIT_PARAM_RENDER_VIEWSTATE_ID} context parameter you can tune this behaviour.
900      * <br/>Set it to
901      * <ul><li>true - to render JSF 1.2 compliant id attributes (that might cause invalid XHTML), or</li>
902      * <li>false - to omit rendering of the id attribute (which is only needed for very special AJAX/Javascript 
903      * components)</li></ul>
904      * Default value is: true (for backwards compatibility and JSF 1.2 compliancy) 
905      * @return true, if the client state hidden input "javax.faces.ViewState" id attribute should be rendered
906      */
907     public boolean isRenderViewStateId()
908     {
909         return _renderViewStateId;
910     }
911 
912     public void setRenderViewStateId(boolean renderViewStateId)
913     {
914         _renderViewStateId = renderViewStateId;
915     }
916 
917     /**
918      * <p>W3C recommends to use the "&amp;amp;" entity instead of a plain "&amp;" character within HTML.
919      * This also applies to attribute values and thus to the "href" attribute of &lt;a&gt; elements as well.
920      * Even more, when XHTML is used as output the usage of plain "&amp;" characters is forbidden and would lead to
921      * invalid XML code.
922      * Therefore, since version 1.1.6 MyFaces renders the correct "&amp;amp;" entity for links.</p>
923      * <p>The init parameter
924      * {@link #INIT_PARAM_STRICT_XHTML_LINKS} makes it possible to restore the old behaviour and to make MyFaces
925      * "bug compatible" to the Sun RI which renders plain "&amp;" chars in links as well.</p>
926      * @see <a href="http://www.w3.org/TR/html401/charset.html#h-5.3.2">HTML 4.01 Specification</a>
927      * @see <a href="http://issues.apache.org/jira/browse/MYFACES-1774">Jira: MYFACES-1774</a>
928      * @return true if ampersand characters ("&amp;") should be correctly rendered as "&amp;amp;" entities 
929      *         within link urls (=default), false for old (XHTML incompatible) behaviour
930      */
931     public boolean isStrictXhtmlLinks()
932     {
933         return _strictXhtmlLinks;
934     }
935 
936     public void setStrictXhtmlLinks(boolean strictXhtmlLinks)
937     {
938         _strictXhtmlLinks = strictXhtmlLinks;
939     }
940 
941     public boolean isTomahawkAvailable()
942     {
943         return TOMAHAWK_AVAILABLE;
944     }
945 
946     public boolean isMyfacesImplAvailable()
947     {
948         return MYFACES_IMPL_AVAILABLE;
949     }
950 
951     public boolean isRiImplAvailable()
952     {
953         return RI_IMPL_AVAILABLE;
954     }
955 
956     /**
957      * Do not use this in renderers directly!
958      * You should use {@link org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils#isJavascriptAllowed}
959      * to determine if javascript is allowed or not.
960      */
961     public boolean isAllowJavascript()
962     {
963         return _allowJavascript;
964     }
965 
966     private void setAllowJavascript(boolean allowJavascript)
967     {
968         _allowJavascript = allowJavascript;
969     }
970 
971     public boolean isAutoScroll()
972     {
973         return _autoScroll;
974     }
975 
976     private void setAutoScroll(boolean autoScroll)
977     {
978         _autoScroll = autoScroll;
979     }
980 
981     private void setAddResourceClass(String addResourceClass)
982     {
983         _addResourceClass = addResourceClass;
984     }
985 
986     public String getAddResourceClass()
987     {
988         return _addResourceClass;
989     }
990 
991     /**
992      * ExtensionFilter needs access to AddResourceClass init param without having
993      * an ExternalContext at hand.
994      */
995     public static String getAddResourceClassFromServletContext(ServletContext servletContext)
996     {
997         String addResourceClass = servletContext.getInitParameter(INIT_PARAM_ADD_RESOURCE_CLASS);
998 
999         return addResourceClass == null ? INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT : addResourceClass;
1000     }
1001 
1002     /**
1003      * Should the environment be checked so that the ExtensionsFilter will work properly. 
1004      */
1005     public boolean isCheckExtensionsFilter()
1006     {
1007         return _checkExtensionsFilter;
1008     }
1009 
1010     public void setCheckExtensionsFilter(boolean extensionsFilter)
1011     {
1012         _checkExtensionsFilter = extensionsFilter;
1013     }
1014 
1015     /**
1016      * 
1017      */
1018     public boolean isViewStateJavascript()
1019     {
1020         return _viewStateJavascript;
1021     }
1022 
1023     private void setViewStateJavascript(boolean viewStateJavascript)
1024     {
1025         _viewStateJavascript = viewStateJavascript;
1026     }
1027 
1028     public void setRenderClearJavascriptOnButton(
1029             boolean renderClearJavascriptOnButton)
1030     {
1031         _renderClearJavascriptOnButton = renderClearJavascriptOnButton;
1032     }
1033 
1034     /**
1035      * This param renders the clear javascript on button necessary only for
1036      * compatibility with hidden fields feature of myfaces. This is done 
1037      * because jsf ri does not render javascript on onclick method for button,
1038      * so myfaces should do this.
1039      * 
1040      * @return
1041      */
1042     public boolean isRenderClearJavascriptOnButton()
1043     {
1044         return _renderClearJavascriptOnButton;
1045     }
1046 
1047     public boolean isRenderHiddenFieldsForLinkParams()
1048     {
1049         return renderHiddenFieldsForLinkParams;
1050     }
1051 
1052     public void setRenderHiddenFieldsForLinkParams(
1053             boolean renderHiddenFieldsForLinkParams)
1054     {
1055         this.renderHiddenFieldsForLinkParams = renderHiddenFieldsForLinkParams;
1056     }
1057 
1058     public void setSaveFormSubmitLinkIE(boolean saveFormSubmitLinkIE)
1059     {
1060         _saveFormSubmitLinkIE = saveFormSubmitLinkIE;
1061     }
1062 
1063     /**
1064      * Add a code that save the form when submit a form using a
1065      * link. It's a bug on IE.
1066      * 
1067      * @return
1068      */
1069     public boolean isSaveFormSubmitLinkIE()
1070     {
1071         return _saveFormSubmitLinkIE;
1072     }
1073     
1074     public String getDelegateFacesServlet()
1075     {
1076         return _delegateFacesServlet;
1077     }
1078     
1079     public void setDelegateFacesServlet(String delegateFacesServlet)
1080     {
1081         _delegateFacesServlet = delegateFacesServlet;
1082     }
1083 
1084     public boolean isRefreshTransientBuildOnPSS()
1085     {
1086         return _refreshTransientBuildOnPSS;
1087     }
1088 
1089     public void setRefreshTransientBuildOnPSS(boolean refreshTransientBuildOnPSS)
1090     {
1091         this._refreshTransientBuildOnPSS = refreshTransientBuildOnPSS;
1092     }
1093 
1094     public boolean isRefreshTransientBuildOnPSSAuto()
1095     {
1096         return _refreshTransientBuildOnPSSAuto;
1097     }
1098 
1099     public void setRefreshTransientBuildOnPSSAuto(
1100             boolean refreshTransientBuildOnPSSAuto)
1101     {
1102         this._refreshTransientBuildOnPSSAuto = refreshTransientBuildOnPSSAuto;
1103     }
1104 
1105     public boolean isRefreshTransientBuildOnPSSPreserveState()
1106     {
1107         return refreshTransientBuildOnPSSPreserveState;
1108     }
1109 
1110     public void setRefreshTransientBuildOnPSSPreserveState(
1111             boolean refreshTransientBuildOnPSSPreserveState)
1112     {
1113         this.refreshTransientBuildOnPSSPreserveState = refreshTransientBuildOnPSSPreserveState;
1114     }
1115     
1116     public boolean isValidateXML()
1117     {
1118         return _validateXML;
1119     }
1120 
1121     public void setValidateXML(boolean validateXML)
1122     {
1123         _validateXML = validateXML;
1124     }
1125 
1126     public boolean isWrapScriptContentWithXmlCommentTag()
1127     {
1128         return _wrapScriptContentWithXmlCommentTag;
1129     }
1130 
1131     public void setWrapScriptContentWithXmlCommentTag(
1132             boolean wrapScriptContentWithXmlCommentTag)
1133     {
1134         this._wrapScriptContentWithXmlCommentTag = wrapScriptContentWithXmlCommentTag;
1135     }
1136 
1137     public boolean isRenderFormSubmitScriptInline()
1138     {
1139         return _renderFormSubmitScriptInline;
1140     }
1141 
1142     public void setRenderFormSubmitScriptInline(
1143             boolean renderFormSubmitScriptInline)
1144     {
1145         _renderFormSubmitScriptInline = renderFormSubmitScriptInline;
1146     }
1147 
1148     public boolean isDebugPhaseListenerEnabled()
1149     {
1150         return _debugPhaseListenerEnabled;
1151     }
1152 
1153     public void setDebugPhaseListenerEnabled(boolean debugPhaseListener)
1154     {
1155         this._debugPhaseListenerEnabled = debugPhaseListener;
1156     }
1157 
1158     public boolean isStrictJsf2RefreshTargetAjax()
1159     {
1160         return _strictJsf2RefreshTargetAjax;
1161     }
1162 
1163     public void setStrictJsf2RefreshTargetAjax(boolean strictJsf2RefreshTargetAjax)
1164     {
1165         this._strictJsf2RefreshTargetAjax = strictJsf2RefreshTargetAjax;
1166     }
1167 
1168     public boolean isStrictJsf2CCELResolver()
1169     {
1170         return _strictJsf2CCELResolver;
1171     }
1172 
1173     public void setStrictJsf2CCELResolver(boolean strictJsf2CCELResolver)
1174     {
1175         this._strictJsf2CCELResolver = strictJsf2CCELResolver;
1176     }
1177 
1178     public String getDefaultResponseWriterContentTypeMode()
1179     {
1180         return _defaultResponseWriterContentTypeMode;
1181     }
1182 
1183     public void setDefaultResponseWriterContentTypeMode(
1184             String defaultResponseWriterContentTypeMode)
1185     {
1186         this._defaultResponseWriterContentTypeMode = defaultResponseWriterContentTypeMode;
1187     }
1188 
1189     public boolean isViewUniqueIdsCacheEnabled()
1190     {
1191         return _viewUniqueIdsCacheEnabled;
1192     }
1193 
1194     public void setViewUniqueIdsCacheEnabled(boolean viewUniqueIdsCacheEnabled)
1195     {
1196         _viewUniqueIdsCacheEnabled = viewUniqueIdsCacheEnabled;
1197     }
1198 
1199     public boolean isSupportJSPAndFacesEL()
1200     {
1201         return _supportJSPAndFacesEL;
1202     }
1203 
1204     public void setSupportJSPAndFacesEL(
1205             boolean supportJSPANDFacesEL)
1206     {
1207         _supportJSPAndFacesEL = supportJSPANDFacesEL;
1208     }
1209 
1210     public int getComponentUniqueIdsCacheSize()
1211     {
1212         return _componentUniqueIdsCacheSize;
1213     }
1214 
1215     public void setComponentUniqueIdsCacheSize(int componentUniqueIdsCacheSize)
1216     {
1217         this._componentUniqueIdsCacheSize = componentUniqueIdsCacheSize;
1218     }
1219 
1220     public String getGaeJsfJarFiles()
1221     {
1222         return _gaeJsfJarFiles;
1223     }
1224 
1225     public void setGaeJsfJarFiles(String gaeJsfJarFiles)
1226     {
1227         this._gaeJsfJarFiles = gaeJsfJarFiles;
1228     }
1229 
1230     public String getGaeJsfAnnotationsJarFiles()
1231     {
1232         return _gaeJsfAnnotationsJarFiles;
1233     }
1234 
1235     public void setGaeJsfAnnotationsJarFiles(String gaeJsfAnnotationsJarFiles)
1236     {
1237         this._gaeJsfAnnotationsJarFiles = gaeJsfAnnotationsJarFiles;
1238     }
1239 
1240     public boolean isStrictJsf2ViewNotFound()
1241     {
1242         return _strictJsf2ViewNotFound;
1243     }
1244 
1245     public void setStrictJsf2ViewNotFound(boolean strictJsf2ViewNotFound)
1246     {
1247         this._strictJsf2ViewNotFound = strictJsf2ViewNotFound;
1248     }
1249 
1250     public boolean isEarlyFlushEnabled()
1251     {
1252         return _earlyFlushEnabled;
1253     }
1254 
1255     public void setEarlyFlushEnabled(boolean earlyFlushEnabled)
1256     {
1257         this._earlyFlushEnabled = earlyFlushEnabled;
1258     }
1259 
1260     public boolean isCdiManagedConvertersEnabled()
1261     {
1262         return _cdiManagedConvertersEnabled;
1263     }
1264 
1265     public void setCdiManagedConvertersEnabled(boolean cdiManagedConvertersEnabled)
1266     {
1267         this._cdiManagedConvertersEnabled = cdiManagedConvertersEnabled;
1268     }
1269 
1270     public boolean isCdiManagedValidatorsEnabled()
1271     {
1272         return _cdiManagedValidatorsEnabled;
1273     }
1274 
1275     public void setCdiManagedValidatorsEnabled(boolean cdiManagedValidatorsEnabled)
1276     {
1277         this._cdiManagedValidatorsEnabled = cdiManagedValidatorsEnabled;
1278     }
1279 
1280     public boolean isStrictJsf2FaceletsCompatibility()
1281     {
1282         return _strictJsf2FaceletsCompatibility;
1283     }
1284 
1285     public void setStrictJsf2FaceletsCompatibility(boolean strictJsf2FaceletsCompatibility)
1286     {
1287         this._strictJsf2FaceletsCompatibility = strictJsf2FaceletsCompatibility;
1288     }
1289 }