1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.shared.config;
20
21 import java.util.logging.Logger;
22
23 import javax.faces.context.ExternalContext;
24 import javax.servlet.ServletContext;
25
26 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
27 import org.apache.myfaces.shared.util.ClassUtils;
28 import org.apache.myfaces.shared.util.WebConfigParamUtils;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class MyfacesConfig
47 {
48
49 private static final Logger log = Logger.getLogger(MyfacesConfig.class.getName());
50
51 private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
52
53
54
55
56
57 @JSFWebConfigParam(tags="tomahawk")
58 public static final String INIT_PARAM_RESOURCE_VIRTUAL_PATH = "org.apache.myfaces.RESOURCE_VIRTUAL_PATH";
59 public static final String INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT = "/faces/myFacesExtensionResource";
60
61
62
63
64
65
66 @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1",
67 ignoreUpperLowerCase=true, group="render")
68 private static final String INIT_PARAM_PRETTY_HTML = "org.apache.myfaces.PRETTY_HTML";
69 private static final boolean INIT_PARAM_PRETTY_HTML_DEFAULT = true;
70
71
72
73
74
75
76
77
78
79 @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1",
80 ignoreUpperLowerCase=true, group="render")
81 private static final String INIT_PARAM_ALLOW_JAVASCRIPT = "org.apache.myfaces.ALLOW_JAVASCRIPT";
82 private static final boolean INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT = true;
83
84
85
86
87 @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1",
88 ignoreUpperLowerCase=true, deprecated=true, tags="tomahawk", group="render")
89 private static final String INIT_PARAM_DETECT_JAVASCRIPT = "org.apache.myfaces.DETECT_JAVASCRIPT";
90 private static final boolean INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT = false;
91
92
93
94
95
96
97
98
99 @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1",
100 ignoreUpperLowerCase=true, tags="tomahawk")
101 private static final String INIT_PARAM_AUTO_SCROLL = "org.apache.myfaces.AUTO_SCROLL";
102 private static final boolean INIT_PARAM_AUTO_SCROLL_DEFAULT = false;
103
104
105
106
107
108
109
110
111
112
113
114 @JSFWebConfigParam(defaultValue="org.apache.myfaces. renderkit.html.util. DefaultAddResource",since="1.1",
115 desc="Tomahawk specific: Indicate the class responsible to place scripts and css using " +
116 "tomahawk AddResource API", tags="tomahawk")
117 private static final String INIT_PARAM_ADD_RESOURCE_CLASS = "org.apache.myfaces.ADD_RESOURCE_CLASS";
118 private static final String INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT =
119 "org.apache.myfaces.renderkit.html.util.DefaultAddResource";
120
121
122
123
124
125
126
127
128
129
130
131
132
133 @JSFWebConfigParam(defaultValue="for JSF 2.0 since 1.1.11 false, otherwise true",
134 expectedValues="true, false, on, off, yes, no",since="1.1", ignoreUpperLowerCase=true,
135 desc="Tomahawk specific: This parameter will check for a properly configured Extensions-Filter if " +
136 "it is needed by the web-app.", tags="tomahawk")
137 private static final String INIT_CHECK_EXTENSIONS_FILTER = "org.apache.myfaces.CHECK_EXTENSIONS_FILTER";
138 private static final boolean INIT_CHECK_EXTENSIONS_FILTER_DEFAULT = false;
139
140
141
142
143 @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1",
144 ignoreUpperLowerCase=true, tags="tomahawk", group="render")
145 private static final String INIT_READONLY_AS_DISABLED_FOR_SELECT =
146 "org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS";
147 private static final boolean INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT = true;
148
149
150
151
152
153
154 @JSFWebConfigParam(defaultValue="2",since="1.1", classType="java.lang.Long")
155 public static final String INIT_PARAM_CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
156 public static final long INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT = 2;
157
158
159
160
161 @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1",
162 ignoreUpperLowerCase=true, deprecated=true, group="state")
163 private static final String INIT_PARAM_VIEWSTATE_JAVASCRIPT = "org.apache.myfaces.VIEWSTATE_JAVASCRIPT";
164 private static final boolean INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT = false;
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181 @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1",
182 ignoreUpperLowerCase=true, group="state")
183 private static final String INIT_PARAM_RENDER_VIEWSTATE_ID = "org.apache.myfaces.RENDER_VIEWSTATE_ID";
184 private static final boolean INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT = true;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 @JSFWebConfigParam(defaultValue="true", expectedValues="true, false, on, off, yes, no",since="1.1.6",
202 ignoreUpperLowerCase=true, group="render")
203 private static final String INIT_PARAM_STRICT_XHTML_LINKS = "org.apache.myfaces.STRICT_XHTML_LINKS";
204 private static final boolean INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT = true;
205
206
207
208
209
210
211
212 @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.2.3",
213 ignoreUpperLowerCase=true, group="render")
214 private static final String INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON =
215 "org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON";
216 private static final boolean INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT= false;
217
218
219
220
221
222
223
224
225 @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.2.9",
226 ignoreUpperLowerCase=true, group="render")
227 private static final String INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS =
228 "org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS";
229 private static final boolean INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT= false;
230
231
232
233
234
235 @JSFWebConfigParam(defaultValue="false", expectedValues="true, false, on, off, yes, no",since="1.1",
236 ignoreUpperLowerCase=true, group="render")
237 private static final String INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE = "org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE";
238 private static final boolean INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT = false;
239
240
241
242
243
244
245
246
247
248 @JSFWebConfigParam(since="1.2.7")
249 private static final String INIT_PARAM_DELEGATE_FACES_SERVLET = "org.apache.myfaces.DELEGATE_FACES_SERVLET";
250
251
252
253
254
255
256
257
258
259
260
261
262 @JSFWebConfigParam(since="2.0", defaultValue="auto", expectedValues="true,false,auto", tags="performance",
263 ignoreUpperLowerCase=true, group="state")
264 public final static String INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS =
265 "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS";
266 public final static String INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT = "auto";
267
268
269
270
271
272
273
274
275
276
277 @JSFWebConfigParam(since="2.0", defaultValue="false", expectedValues="true, false, on, off, yes, no",
278 tags="performance", ignoreUpperLowerCase=true, group="state")
279 public final static String INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE =
280 "org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE";
281 public final static boolean INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT = false;
282
283
284
285
286
287 @JSFWebConfigParam(since="2.0", expectedValues="true, false, on, off, yes, no", ignoreUpperLowerCase=true)
288 public final static String INIT_PARAM_VALIDATE_XML = "org.apache.myfaces.VALIDATE_XML";
289 public final static boolean INIT_PARAM_VALIDATE_XML_DEFAULT = false;
290
291
292
293
294 @JSFWebConfigParam(since="2.0.1", expectedValues="true, false, on, off, yes, no", defaultValue="true",
295 ignoreUpperLowerCase=true, group="render")
296 public final static String INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG =
297 "org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG";
298 public final static boolean INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT = true;
299
300
301
302
303 @JSFWebConfigParam(since="2.0.2", expectedValues="true, false, on, off, yes, no", defaultValue="false",
304 ignoreUpperLowerCase=true, group="render")
305 public final static String INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE =
306 "org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE";
307 public final static boolean INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT = false;
308
309
310
311
312
313
314
315
316 @JSFWebConfigParam(since="2.0.8")
317 public final static String INIT_PARAM_DEBUG_PHASE_LISTENER = "org.apache.myfaces.DEBUG_PHASE_LISTENER";
318 public final static boolean INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT = false;
319
320
321
322
323
324
325
326
327 @JSFWebConfigParam(since="2.0.10", expectedValues="true, false", defaultValue="false")
328 public final static String INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX =
329 "org.apache.myfaces.STRICT_JSF_2_REFRESH_TARGET_AJAX";
330 public final static boolean INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT = false;
331
332
333
334
335
336
337
338
339
340
341
342 @JSFWebConfigParam(since="2.0.10", expectedValues="true, false", defaultValue="false", group="EL")
343 public final static String INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER =
344 "org.apache.myfaces.STRICT_JSF_2_CC_EL_RESOLVER";
345 public final static boolean INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT = false;
346
347
348
349
350
351 @JSFWebConfigParam(since="2.0.11,2.1.5", expectedValues="text/html, application/xhtml+xml",
352 defaultValue="text/html", group="render")
353 public final static String INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE =
354 "org.apache.myfaces.DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE";
355 public final static String INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT = "text/html";
356
357
358
359
360
361 @JSFWebConfigParam(defaultValue = "false", since = "2.0.13, 2.1.7", expectedValues="true, false",
362 group="viewhandler", tags="performance",
363 desc="Enable or disable a cache used to 'remember' the generated facelets unique ids " +
364 "and reduce the impact over memory usage.")
365 public static final String INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED =
366 "org.apache.myfaces.VIEW_UNIQUE_IDS_CACHE_ENABLED";
367 public static final boolean INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT = false;
368
369
370
371
372
373 @JSFWebConfigParam(defaultValue = "100", since = "2.0.13, 2.1.7",
374 group="viewhandler", tags="performance")
375 public static final String INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE =
376 "org.apache.myfaces.COMPONENT_UNIQUE_IDS_CACHE_SIZE";
377 public static final int INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT = 100;
378
379
380
381
382
383
384
385
386 @JSFWebConfigParam(since="2.0.13,2.1.7", expectedValues="true,false", defaultValue="true",
387 desc="If set false, myfaces won't support JSP and javax.faces.el. JSP are deprecated in " +
388 "JSF 2.X, javax.faces.el in in JSF 1.2. Default value is true.",
389 group="EL", tags="performance ")
390 public final static String INIT_PARAM_SUPPORT_JSP_AND_FACES_EL = "org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL";
391 public final static boolean INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT = true;
392
393
394
395
396
397
398
399
400 @JSFWebConfigParam(since = "2.1.8, 2.0.14", expectedValues="none, myfavoritejsflib-*.jar",
401 tags="performance, GAE")
402 public static final String INIT_PARAM_GAE_JSF_JAR_FILES = "org.apache.myfaces.GAE_JSF_JAR_FILES";
403 public final static String INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT = null;
404
405
406
407
408
409
410
411
412
413
414
415 @JSFWebConfigParam(since = "2.1.8, 2.0.14", expectedValues="none, myfavoritejsflib-*.jar",
416 tags="performance, GAE")
417 public static final String INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES =
418 "org.apache.myfaces.GAE_JSF_ANNOTATIONS_JAR_FILES";
419 public final static String INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT = null;
420
421 private boolean _prettyHtml;
422 private boolean _detectJavascript;
423 private boolean _allowJavascript;
424 private boolean _autoScroll;
425 private String _addResourceClass;
426 private String _resourceVirtualPath;
427 private boolean _checkExtensionsFilter;
428 private boolean _readonlyAsDisabledForSelect;
429 private long _configRefreshPeriod;
430 private boolean _viewStateJavascript;
431 private boolean _renderViewStateId;
432 private boolean _strictXhtmlLinks;
433 private boolean _renderClearJavascriptOnButton;
434 private boolean renderHiddenFieldsForLinkParams;
435 private boolean _saveFormSubmitLinkIE;
436 private String _delegateFacesServlet;
437 private boolean _refreshTransientBuildOnPSS;
438 private boolean _refreshTransientBuildOnPSSAuto;
439 private boolean refreshTransientBuildOnPSSPreserveState;
440 private boolean _validateXML;
441 private boolean _wrapScriptContentWithXmlCommentTag;
442 private boolean _renderFormSubmitScriptInline;
443 private boolean _debugPhaseListenerEnabled;
444 private boolean _strictJsf2RefreshTargetAjax;
445 private boolean _strictJsf2CCELResolver;
446 private String _defaultResponseWriterContentTypeMode;
447 private boolean _viewUniqueIdsCacheEnabled;
448 private int _componentUniqueIdsCacheSize;
449 private boolean _supportJSPAndFacesEL;
450 private String _gaeJsfJarFiles;
451 private String _gaeJsfAnnotationsJarFiles;
452
453 private static final boolean TOMAHAWK_AVAILABLE;
454 private static final boolean MYFACES_IMPL_AVAILABLE;
455 private static final boolean RI_IMPL_AVAILABLE;
456
457 static
458 {
459 boolean tomahawkAvailable;
460 try
461 {
462 ClassUtils.classForName("org.apache.myfaces.webapp.filter.ExtensionsFilter");
463 tomahawkAvailable = true;
464 }
465 catch (ClassNotFoundException e)
466 {
467 tomahawkAvailable = false;
468 }
469 TOMAHAWK_AVAILABLE = tomahawkAvailable;
470 }
471
472 static
473 {
474 boolean myfacesImplAvailable;
475 try
476 {
477 ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
478 myfacesImplAvailable = true;
479 }
480 catch (ClassNotFoundException e)
481 {
482 myfacesImplAvailable = false;
483 }
484 MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
485 }
486
487 static
488 {
489 boolean riImplAvailable;
490 try
491 {
492 ClassUtils.classForName("com.sun.faces.application.ApplicationImpl");
493 riImplAvailable = true;
494 }
495 catch (ClassNotFoundException e)
496 {
497 riImplAvailable = false;
498 }
499 RI_IMPL_AVAILABLE = riImplAvailable;
500 }
501
502 public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
503 {
504 MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx
505 .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
506 if (myfacesConfig == null)
507 {
508
509 myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
510
511 extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
512
513 }
514
515 return myfacesConfig;
516 }
517
518 public MyfacesConfig()
519 {
520 setPrettyHtml(INIT_PARAM_PRETTY_HTML_DEFAULT);
521 setAllowJavascript(INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT);
522 setRenderClearJavascriptOnButton(INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT);
523 setRenderHiddenFieldsForLinkParams(INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT);
524 setSaveFormSubmitLinkIE(INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT);
525 setReadonlyAsDisabledForSelect(INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT);
526 setRenderViewStateId(INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT);
527 setStrictXhtmlLinks(INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT);
528 setConfigRefreshPeriod(INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT);
529 setViewStateJavascript(INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT);
530 setRefreshTransientBuildOnPSS(true);
531 setRefreshTransientBuildOnPSSAuto(true);
532 setRefreshTransientBuildOnPSSPreserveState(INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT);
533 setValidateXML(INIT_PARAM_VALIDATE_XML_DEFAULT);
534 setWrapScriptContentWithXmlCommentTag(INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT);
535 setDetectJavascript(INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT);
536 setAutoScroll(INIT_PARAM_AUTO_SCROLL_DEFAULT);
537 setAddResourceClass(INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT);
538 setResourceVirtualPath(INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT);
539
540
541 setCheckExtensionsFilter(false);
542 setRenderFormSubmitScriptInline(INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT);
543 setDebugPhaseListenerEnabled(INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT);
544 setStrictJsf2RefreshTargetAjax(INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT);
545 setStrictJsf2CCELResolver(INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT);
546 setDefaultResponseWriterContentTypeMode(INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT);
547 setViewUniqueIdsCacheEnabled(INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT);
548 setComponentUniqueIdsCacheSize(INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT);
549 setSupportJSPAndFacesEL(INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT);
550 setGaeJsfJarFiles(INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT);
551 setGaeJsfAnnotationsJarFiles(INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT);
552 }
553
554 private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx)
555 {
556
557 MyfacesConfig myfacesConfig = new MyfacesConfig();
558
559 myfacesConfig.setPrettyHtml(getBooleanInitParameter(extCtx, INIT_PARAM_PRETTY_HTML,
560 INIT_PARAM_PRETTY_HTML_DEFAULT));
561 myfacesConfig.setAllowJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_ALLOW_JAVASCRIPT,
562 INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT));
563
564 myfacesConfig.setRenderClearJavascriptOnButton(getBooleanInitParameter(extCtx,
565 INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON,
566 INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT));
567
568 myfacesConfig.setRenderHiddenFieldsForLinkParams(getBooleanInitParameter(extCtx,
569 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS,
570 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT));
571
572 myfacesConfig.setSaveFormSubmitLinkIE(getBooleanInitParameter(extCtx, INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE,
573 INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT));
574
575 myfacesConfig.setReadonlyAsDisabledForSelect(getBooleanInitParameter(extCtx,
576 INIT_READONLY_AS_DISABLED_FOR_SELECT,
577 INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT));
578 myfacesConfig.setRenderViewStateId(getBooleanInitParameter(extCtx, INIT_PARAM_RENDER_VIEWSTATE_ID,
579 INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT));
580 myfacesConfig.setStrictXhtmlLinks(getBooleanInitParameter(extCtx, INIT_PARAM_STRICT_XHTML_LINKS,
581 INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT));
582 myfacesConfig.setRenderFormSubmitScriptInline(getBooleanInitParameter(extCtx,
583 INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE,
584 INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT));
585
586 myfacesConfig.setConfigRefreshPeriod(getLongInitParameter(extCtx, INIT_PARAM_CONFIG_REFRESH_PERIOD,
587 INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT));
588
589 myfacesConfig.setViewStateJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_VIEWSTATE_JAVASCRIPT,
590 INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT));
591
592 myfacesConfig.setDelegateFacesServlet(extCtx.getInitParameter(INIT_PARAM_DELEGATE_FACES_SERVLET));
593
594 String refreshTransientBuildOnPSS = getStringInitParameter(extCtx,
595 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS,
596 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT);
597
598 if (refreshTransientBuildOnPSS == null)
599 {
600 myfacesConfig.setRefreshTransientBuildOnPSS(false);
601 myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
602 }
603 else if ("auto".equalsIgnoreCase(refreshTransientBuildOnPSS))
604 {
605 myfacesConfig.setRefreshTransientBuildOnPSS(true);
606 myfacesConfig.setRefreshTransientBuildOnPSSAuto(true);
607 }
608 else if (refreshTransientBuildOnPSS.equalsIgnoreCase("true") ||
609 refreshTransientBuildOnPSS.equalsIgnoreCase("on") ||
610 refreshTransientBuildOnPSS.equalsIgnoreCase("yes"))
611 {
612 myfacesConfig.setRefreshTransientBuildOnPSS(true);
613 myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
614 }
615 else
616 {
617 myfacesConfig.setRefreshTransientBuildOnPSS(false);
618 myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
619 }
620
621 myfacesConfig.setRefreshTransientBuildOnPSSPreserveState(getBooleanInitParameter(extCtx,
622 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE,
623 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT));
624
625 myfacesConfig.setValidateXML(getBooleanInitParameter(extCtx, INIT_PARAM_VALIDATE_XML,
626 INIT_PARAM_VALIDATE_XML_DEFAULT));
627
628 myfacesConfig.setWrapScriptContentWithXmlCommentTag(getBooleanInitParameter(extCtx,
629 INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG,
630 INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT));
631
632 myfacesConfig.setDebugPhaseListenerEnabled(getBooleanInitParameter(extCtx, INIT_PARAM_DEBUG_PHASE_LISTENER,
633 INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT));
634
635 myfacesConfig.setStrictJsf2RefreshTargetAjax(WebConfigParamUtils.getBooleanInitParameter(extCtx,
636 INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX, INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT));
637
638 myfacesConfig.setStrictJsf2CCELResolver(WebConfigParamUtils.getBooleanInitParameter(extCtx,
639 INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER, INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT));
640
641 myfacesConfig.setDefaultResponseWriterContentTypeMode(WebConfigParamUtils.getStringInitParameter(
642 extCtx, INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE,
643 INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT));
644
645 myfacesConfig.setViewUniqueIdsCacheEnabled(WebConfigParamUtils.getBooleanInitParameter(extCtx,
646 INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED, INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT));
647 myfacesConfig.setComponentUniqueIdsCacheSize(
648 WebConfigParamUtils.getIntegerInitParameter(extCtx,
649 INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE,
650 INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT));
651 myfacesConfig.setSupportJSPAndFacesEL(WebConfigParamUtils.getBooleanInitParameter(extCtx,
652 INIT_PARAM_SUPPORT_JSP_AND_FACES_EL, INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT));
653
654 myfacesConfig.setGaeJsfJarFiles(WebConfigParamUtils.getStringInitParameter(extCtx,
655 INIT_PARAM_GAE_JSF_JAR_FILES, INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT));
656 myfacesConfig.setGaeJsfAnnotationsJarFiles(WebConfigParamUtils.getStringInitParameter(extCtx,
657 INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES, INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT));
658
659 if (TOMAHAWK_AVAILABLE)
660 {
661 myfacesConfig.setDetectJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_DETECT_JAVASCRIPT,
662 INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT));
663 myfacesConfig.setAutoScroll(getBooleanInitParameter(extCtx, INIT_PARAM_AUTO_SCROLL,
664 INIT_PARAM_AUTO_SCROLL_DEFAULT));
665
666 myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
667 INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
668 myfacesConfig.setResourceVirtualPath(getStringInitParameter(extCtx, INIT_PARAM_RESOURCE_VIRTUAL_PATH,
669 INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT));
670
671 myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
672 INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689 }
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706 return myfacesConfig;
707 }
708
709 private static boolean getBooleanInitParameter(ExternalContext externalContext,
710 String paramName,
711 boolean defaultValue)
712 {
713 String strValue = externalContext.getInitParameter(paramName);
714 if (strValue == null)
715 {
716
717
718 return defaultValue;
719 }
720 else if (strValue.equalsIgnoreCase("true") || strValue.equalsIgnoreCase("on") ||
721 strValue.equalsIgnoreCase("yes"))
722 {
723 return true;
724 }
725 else if (strValue.equalsIgnoreCase("false") || strValue.equalsIgnoreCase("off") ||
726 strValue.equalsIgnoreCase("no"))
727 {
728 return false;
729 }
730 else
731 {
732
733
734 return defaultValue;
735 }
736 }
737
738 private static String getStringInitParameter(ExternalContext externalContext,
739 String paramName,
740 String defaultValue)
741 {
742 String strValue = externalContext.getInitParameter(paramName);
743 if (strValue == null)
744 {
745
746
747
748 return defaultValue;
749 }
750
751 return strValue;
752 }
753
754 private static long getLongInitParameter(ExternalContext externalContext,
755 String paramName,
756 long defaultValue)
757 {
758 String strValue = externalContext.getInitParameter(paramName);
759 if (strValue == null)
760 {
761
762
763 return defaultValue;
764 }
765 else
766 {
767 try
768 {
769 return Long.parseLong(strValue);
770 }
771 catch (NumberFormatException e)
772 {
773
774
775 }
776 return defaultValue;
777 }
778 }
779
780 private void setResourceVirtualPath( String resourceVirtualPath )
781 {
782 this._resourceVirtualPath = resourceVirtualPath;
783 }
784
785 public String getResourceVirtualPath()
786 {
787 return this._resourceVirtualPath;
788 }
789
790 public boolean isPrettyHtml()
791 {
792 return _prettyHtml;
793 }
794
795 private void setPrettyHtml(boolean prettyHtml)
796 {
797 _prettyHtml = prettyHtml;
798 }
799
800 public boolean isDetectJavascript()
801 {
802 return _detectJavascript;
803 }
804
805 private void setDetectJavascript(boolean detectJavascript)
806 {
807 _detectJavascript = detectJavascript;
808 }
809
810 private void setReadonlyAsDisabledForSelect(boolean readonlyAsDisabledForSelect)
811 {
812 _readonlyAsDisabledForSelect = readonlyAsDisabledForSelect;
813 }
814
815 public boolean isReadonlyAsDisabledForSelect()
816 {
817 return _readonlyAsDisabledForSelect;
818 }
819
820
821 public long getConfigRefreshPeriod()
822 {
823 return _configRefreshPeriod;
824 }
825
826 public void setConfigRefreshPeriod(long configRefreshPeriod)
827 {
828 _configRefreshPeriod = configRefreshPeriod;
829 }
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844 public boolean isRenderViewStateId()
845 {
846 return _renderViewStateId;
847 }
848
849 public void setRenderViewStateId(boolean renderViewStateId)
850 {
851 _renderViewStateId = renderViewStateId;
852 }
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868 public boolean isStrictXhtmlLinks()
869 {
870 return _strictXhtmlLinks;
871 }
872
873 public void setStrictXhtmlLinks(boolean strictXhtmlLinks)
874 {
875 _strictXhtmlLinks = strictXhtmlLinks;
876 }
877
878 public boolean isTomahawkAvailable()
879 {
880 return TOMAHAWK_AVAILABLE;
881 }
882
883 public boolean isMyfacesImplAvailable()
884 {
885 return MYFACES_IMPL_AVAILABLE;
886 }
887
888 public boolean isRiImplAvailable()
889 {
890 return RI_IMPL_AVAILABLE;
891 }
892
893
894
895
896
897
898 public boolean isAllowJavascript()
899 {
900 return _allowJavascript;
901 }
902
903 private void setAllowJavascript(boolean allowJavascript)
904 {
905 _allowJavascript = allowJavascript;
906 }
907
908 public boolean isAutoScroll()
909 {
910 return _autoScroll;
911 }
912
913 private void setAutoScroll(boolean autoScroll)
914 {
915 _autoScroll = autoScroll;
916 }
917
918 private void setAddResourceClass(String addResourceClass)
919 {
920 _addResourceClass = addResourceClass;
921 }
922
923 public String getAddResourceClass()
924 {
925 return _addResourceClass;
926 }
927
928
929
930
931
932 public static String getAddResourceClassFromServletContext(ServletContext servletContext)
933 {
934 String addResourceClass = servletContext.getInitParameter(INIT_PARAM_ADD_RESOURCE_CLASS);
935
936 return addResourceClass == null ? INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT : addResourceClass;
937 }
938
939
940
941
942 public boolean isCheckExtensionsFilter()
943 {
944 return _checkExtensionsFilter;
945 }
946
947 public void setCheckExtensionsFilter(boolean extensionsFilter)
948 {
949 _checkExtensionsFilter = extensionsFilter;
950 }
951
952
953
954
955 public boolean isViewStateJavascript()
956 {
957 return _viewStateJavascript;
958 }
959
960 private void setViewStateJavascript(boolean viewStateJavascript)
961 {
962 _viewStateJavascript = viewStateJavascript;
963 }
964
965 public void setRenderClearJavascriptOnButton(
966 boolean renderClearJavascriptOnButton)
967 {
968 _renderClearJavascriptOnButton = renderClearJavascriptOnButton;
969 }
970
971
972
973
974
975
976
977
978
979 public boolean isRenderClearJavascriptOnButton()
980 {
981 return _renderClearJavascriptOnButton;
982 }
983
984 public boolean isRenderHiddenFieldsForLinkParams()
985 {
986 return renderHiddenFieldsForLinkParams;
987 }
988
989 public void setRenderHiddenFieldsForLinkParams(
990 boolean renderHiddenFieldsForLinkParams)
991 {
992 this.renderHiddenFieldsForLinkParams = renderHiddenFieldsForLinkParams;
993 }
994
995 public void setSaveFormSubmitLinkIE(boolean saveFormSubmitLinkIE)
996 {
997 _saveFormSubmitLinkIE = saveFormSubmitLinkIE;
998 }
999
1000
1001
1002
1003
1004
1005
1006 public boolean isSaveFormSubmitLinkIE()
1007 {
1008 return _saveFormSubmitLinkIE;
1009 }
1010
1011 public String getDelegateFacesServlet()
1012 {
1013 return _delegateFacesServlet;
1014 }
1015
1016 public void setDelegateFacesServlet(String delegateFacesServlet)
1017 {
1018 _delegateFacesServlet = delegateFacesServlet;
1019 }
1020
1021 public boolean isRefreshTransientBuildOnPSS()
1022 {
1023 return _refreshTransientBuildOnPSS;
1024 }
1025
1026 public void setRefreshTransientBuildOnPSS(boolean refreshTransientBuildOnPSS)
1027 {
1028 this._refreshTransientBuildOnPSS = refreshTransientBuildOnPSS;
1029 }
1030
1031 public boolean isRefreshTransientBuildOnPSSAuto()
1032 {
1033 return _refreshTransientBuildOnPSSAuto;
1034 }
1035
1036 public void setRefreshTransientBuildOnPSSAuto(
1037 boolean refreshTransientBuildOnPSSAuto)
1038 {
1039 this._refreshTransientBuildOnPSSAuto = refreshTransientBuildOnPSSAuto;
1040 }
1041
1042 public boolean isRefreshTransientBuildOnPSSPreserveState()
1043 {
1044 return refreshTransientBuildOnPSSPreserveState;
1045 }
1046
1047 public void setRefreshTransientBuildOnPSSPreserveState(
1048 boolean refreshTransientBuildOnPSSPreserveState)
1049 {
1050 this.refreshTransientBuildOnPSSPreserveState = refreshTransientBuildOnPSSPreserveState;
1051 }
1052
1053 public boolean isValidateXML()
1054 {
1055 return _validateXML;
1056 }
1057
1058 public void setValidateXML(boolean validateXML)
1059 {
1060 _validateXML = validateXML;
1061 }
1062
1063 public boolean isWrapScriptContentWithXmlCommentTag()
1064 {
1065 return _wrapScriptContentWithXmlCommentTag;
1066 }
1067
1068 public void setWrapScriptContentWithXmlCommentTag(
1069 boolean wrapScriptContentWithXmlCommentTag)
1070 {
1071 this._wrapScriptContentWithXmlCommentTag = wrapScriptContentWithXmlCommentTag;
1072 }
1073
1074 public boolean isRenderFormSubmitScriptInline()
1075 {
1076 return _renderFormSubmitScriptInline;
1077 }
1078
1079 public void setRenderFormSubmitScriptInline(
1080 boolean renderFormSubmitScriptInline)
1081 {
1082 _renderFormSubmitScriptInline = renderFormSubmitScriptInline;
1083 }
1084
1085 public boolean isDebugPhaseListenerEnabled()
1086 {
1087 return _debugPhaseListenerEnabled;
1088 }
1089
1090 public void setDebugPhaseListenerEnabled(boolean debugPhaseListener)
1091 {
1092 this._debugPhaseListenerEnabled = debugPhaseListener;
1093 }
1094
1095 public boolean isStrictJsf2RefreshTargetAjax()
1096 {
1097 return _strictJsf2RefreshTargetAjax;
1098 }
1099
1100 public void setStrictJsf2RefreshTargetAjax(boolean strictJsf2RefreshTargetAjax)
1101 {
1102 this._strictJsf2RefreshTargetAjax = strictJsf2RefreshTargetAjax;
1103 }
1104
1105 public boolean isStrictJsf2CCELResolver()
1106 {
1107 return _strictJsf2CCELResolver;
1108 }
1109
1110 public void setStrictJsf2CCELResolver(boolean strictJsf2CCELResolver)
1111 {
1112 this._strictJsf2CCELResolver = strictJsf2CCELResolver;
1113 }
1114
1115 public String getDefaultResponseWriterContentTypeMode()
1116 {
1117 return _defaultResponseWriterContentTypeMode;
1118 }
1119
1120 public void setDefaultResponseWriterContentTypeMode(
1121 String defaultResponseWriterContentTypeMode)
1122 {
1123 this._defaultResponseWriterContentTypeMode = defaultResponseWriterContentTypeMode;
1124 }
1125
1126 public boolean isViewUniqueIdsCacheEnabled()
1127 {
1128 return _viewUniqueIdsCacheEnabled;
1129 }
1130
1131 public void setViewUniqueIdsCacheEnabled(boolean viewUniqueIdsCacheEnabled)
1132 {
1133 _viewUniqueIdsCacheEnabled = viewUniqueIdsCacheEnabled;
1134 }
1135
1136 public boolean isSupportJSPAndFacesEL()
1137 {
1138 return _supportJSPAndFacesEL;
1139 }
1140
1141 public void setSupportJSPAndFacesEL(
1142 boolean supportJSPANDFacesEL)
1143 {
1144 _supportJSPAndFacesEL = supportJSPANDFacesEL;
1145 }
1146
1147 public int getComponentUniqueIdsCacheSize()
1148 {
1149 return _componentUniqueIdsCacheSize;
1150 }
1151
1152 public void setComponentUniqueIdsCacheSize(int componentUniqueIdsCacheSize)
1153 {
1154 this._componentUniqueIdsCacheSize = componentUniqueIdsCacheSize;
1155 }
1156
1157 public String getGaeJsfJarFiles()
1158 {
1159 return _gaeJsfJarFiles;
1160 }
1161
1162 public void setGaeJsfJarFiles(String gaeJsfJarFiles)
1163 {
1164 this._gaeJsfJarFiles = gaeJsfJarFiles;
1165 }
1166
1167 public String getGaeJsfAnnotationsJarFiles()
1168 {
1169 return _gaeJsfAnnotationsJarFiles;
1170 }
1171
1172 public void setGaeJsfAnnotationsJarFiles(String gaeJsfAnnotationsJarFiles)
1173 {
1174 this._gaeJsfAnnotationsJarFiles = gaeJsfAnnotationsJarFiles;
1175 }
1176
1177 }