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 private boolean _prettyHtml;
394 private boolean _detectJavascript;
395 private boolean _allowJavascript;
396 private boolean _autoScroll;
397 private String _addResourceClass;
398 private String _resourceVirtualPath;
399 private boolean _checkExtensionsFilter;
400 private boolean _readonlyAsDisabledForSelect;
401 private long _configRefreshPeriod;
402 private boolean _viewStateJavascript;
403 private boolean _renderViewStateId;
404 private boolean _strictXhtmlLinks;
405 private boolean _renderClearJavascriptOnButton;
406 private boolean renderHiddenFieldsForLinkParams;
407 private boolean _saveFormSubmitLinkIE;
408 private String _delegateFacesServlet;
409 private boolean _refreshTransientBuildOnPSS;
410 private boolean _refreshTransientBuildOnPSSAuto;
411 private boolean refreshTransientBuildOnPSSPreserveState;
412 private boolean _validateXML;
413 private boolean _wrapScriptContentWithXmlCommentTag;
414 private boolean _renderFormSubmitScriptInline;
415 private boolean _debugPhaseListenerEnabled;
416 private boolean _strictJsf2RefreshTargetAjax;
417 private boolean _strictJsf2CCELResolver;
418 private String _defaultResponseWriterContentTypeMode;
419 private boolean _viewUniqueIdsCacheEnabled;
420 private int _componentUniqueIdsCacheSize;
421 private boolean _supportJSPAndFacesEL;
422
423 private static final boolean TOMAHAWK_AVAILABLE;
424 private static final boolean MYFACES_IMPL_AVAILABLE;
425 private static final boolean RI_IMPL_AVAILABLE;
426
427 static
428 {
429 boolean tomahawkAvailable;
430 try
431 {
432 ClassUtils.classForName("org.apache.myfaces.webapp.filter.ExtensionsFilter");
433 tomahawkAvailable = true;
434 }
435 catch (ClassNotFoundException e)
436 {
437 tomahawkAvailable = false;
438 }
439 TOMAHAWK_AVAILABLE = tomahawkAvailable;
440 }
441
442 static
443 {
444 boolean myfacesImplAvailable;
445 try
446 {
447 ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
448 myfacesImplAvailable = true;
449 }
450 catch (ClassNotFoundException e)
451 {
452 myfacesImplAvailable = false;
453 }
454 MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
455 }
456
457 static
458 {
459 boolean riImplAvailable;
460 try
461 {
462 ClassUtils.classForName("com.sun.faces.application.ApplicationImpl");
463 riImplAvailable = true;
464 }
465 catch (ClassNotFoundException e)
466 {
467 riImplAvailable = false;
468 }
469 RI_IMPL_AVAILABLE = riImplAvailable;
470 }
471
472 public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
473 {
474 MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx
475 .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
476 if (myfacesConfig == null)
477 {
478
479 myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
480
481 extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
482
483 }
484
485 return myfacesConfig;
486 }
487
488 public MyfacesConfig()
489 {
490 setPrettyHtml(INIT_PARAM_PRETTY_HTML_DEFAULT);
491 setAllowJavascript(INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT);
492 setRenderClearJavascriptOnButton(INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT);
493 setRenderHiddenFieldsForLinkParams(INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT);
494 setSaveFormSubmitLinkIE(INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT);
495 setReadonlyAsDisabledForSelect(INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT);
496 setRenderViewStateId(INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT);
497 setStrictXhtmlLinks(INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT);
498 setConfigRefreshPeriod(INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT);
499 setViewStateJavascript(INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT);
500 setRefreshTransientBuildOnPSS(true);
501 setRefreshTransientBuildOnPSSAuto(true);
502 setRefreshTransientBuildOnPSSPreserveState(INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT);
503 setValidateXML(INIT_PARAM_VALIDATE_XML_DEFAULT);
504 setWrapScriptContentWithXmlCommentTag(INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT);
505 setDetectJavascript(INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT);
506 setAutoScroll(INIT_PARAM_AUTO_SCROLL_DEFAULT);
507 setAddResourceClass(INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT);
508 setResourceVirtualPath(INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT);
509
510
511 setCheckExtensionsFilter(false);
512 setRenderFormSubmitScriptInline(INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT);
513 setDebugPhaseListenerEnabled(INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT);
514 setStrictJsf2RefreshTargetAjax(INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT);
515 setStrictJsf2CCELResolver(INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT);
516 setDefaultResponseWriterContentTypeMode(INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT);
517 setViewUniqueIdsCacheEnabled(INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT);
518 setComponentUniqueIdsCacheSize(INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT);
519 setSupportJSPAndFacesEL(INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT);
520 }
521
522 private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx)
523 {
524
525 MyfacesConfig myfacesConfig = new MyfacesConfig();
526
527 myfacesConfig.setPrettyHtml(getBooleanInitParameter(extCtx, INIT_PARAM_PRETTY_HTML,
528 INIT_PARAM_PRETTY_HTML_DEFAULT));
529 myfacesConfig.setAllowJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_ALLOW_JAVASCRIPT,
530 INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT));
531
532 myfacesConfig.setRenderClearJavascriptOnButton(getBooleanInitParameter(extCtx,
533 INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON,
534 INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT));
535
536 myfacesConfig.setRenderHiddenFieldsForLinkParams(getBooleanInitParameter(extCtx,
537 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS,
538 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT));
539
540 myfacesConfig.setSaveFormSubmitLinkIE(getBooleanInitParameter(extCtx, INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE,
541 INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT));
542
543 myfacesConfig.setReadonlyAsDisabledForSelect(getBooleanInitParameter(extCtx,
544 INIT_READONLY_AS_DISABLED_FOR_SELECT,
545 INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT));
546 myfacesConfig.setRenderViewStateId(getBooleanInitParameter(extCtx, INIT_PARAM_RENDER_VIEWSTATE_ID,
547 INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT));
548 myfacesConfig.setStrictXhtmlLinks(getBooleanInitParameter(extCtx, INIT_PARAM_STRICT_XHTML_LINKS,
549 INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT));
550 myfacesConfig.setRenderFormSubmitScriptInline(getBooleanInitParameter(extCtx,
551 INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE,
552 INIT_PARAM_RENDER_FORM_SUBMIT_SCRIPT_INLINE_DEFAULT));
553
554 myfacesConfig.setConfigRefreshPeriod(getLongInitParameter(extCtx, INIT_PARAM_CONFIG_REFRESH_PERIOD,
555 INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT));
556
557 myfacesConfig.setViewStateJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_VIEWSTATE_JAVASCRIPT,
558 INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT));
559
560 myfacesConfig.setDelegateFacesServlet(extCtx.getInitParameter(INIT_PARAM_DELEGATE_FACES_SERVLET));
561
562 String refreshTransientBuildOnPSS = getStringInitParameter(extCtx,
563 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS,
564 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_DEFAULT);
565
566 if (refreshTransientBuildOnPSS == null)
567 {
568 myfacesConfig.setRefreshTransientBuildOnPSS(false);
569 myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
570 }
571 else if ("auto".equalsIgnoreCase(refreshTransientBuildOnPSS))
572 {
573 myfacesConfig.setRefreshTransientBuildOnPSS(true);
574 myfacesConfig.setRefreshTransientBuildOnPSSAuto(true);
575 }
576 else if (refreshTransientBuildOnPSS.equalsIgnoreCase("true") ||
577 refreshTransientBuildOnPSS.equalsIgnoreCase("on") ||
578 refreshTransientBuildOnPSS.equalsIgnoreCase("yes"))
579 {
580 myfacesConfig.setRefreshTransientBuildOnPSS(true);
581 myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
582 }
583 else
584 {
585 myfacesConfig.setRefreshTransientBuildOnPSS(false);
586 myfacesConfig.setRefreshTransientBuildOnPSSAuto(false);
587 }
588
589 myfacesConfig.setRefreshTransientBuildOnPSSPreserveState(getBooleanInitParameter(extCtx,
590 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE,
591 INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE_DEFAULT));
592
593 myfacesConfig.setValidateXML(getBooleanInitParameter(extCtx, INIT_PARAM_VALIDATE_XML,
594 INIT_PARAM_VALIDATE_XML_DEFAULT));
595
596 myfacesConfig.setWrapScriptContentWithXmlCommentTag(getBooleanInitParameter(extCtx,
597 INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG,
598 INIT_PARAM_WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG_DEFAULT));
599
600 myfacesConfig.setDebugPhaseListenerEnabled(getBooleanInitParameter(extCtx, INIT_PARAM_DEBUG_PHASE_LISTENER,
601 INIT_PARAM_DEBUG_PHASE_LISTENER_DEFAULT));
602
603 myfacesConfig.setStrictJsf2RefreshTargetAjax(WebConfigParamUtils.getBooleanInitParameter(extCtx,
604 INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX, INIT_PARAM_STRICT_JSF_2_REFRESH_TARGET_AJAX_DEFAULT));
605
606 myfacesConfig.setStrictJsf2CCELResolver(WebConfigParamUtils.getBooleanInitParameter(extCtx,
607 INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER, INIT_PARAM_STRICT_JSF_2_CC_EL_RESOLVER_DEFAULT));
608
609 myfacesConfig.setDefaultResponseWriterContentTypeMode(WebConfigParamUtils.getStringInitParameter(
610 extCtx, INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE,
611 INIT_PARAM_DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE_DEFAULT));
612
613 myfacesConfig.setViewUniqueIdsCacheEnabled(WebConfigParamUtils.getBooleanInitParameter(extCtx,
614 INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED, INIT_PARAM_VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT));
615 myfacesConfig.setComponentUniqueIdsCacheSize(
616 WebConfigParamUtils.getIntegerInitParameter(extCtx,
617 INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE,
618 INIT_PARAM_COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT));
619 myfacesConfig.setSupportJSPAndFacesEL(WebConfigParamUtils.getBooleanInitParameter(extCtx,
620 INIT_PARAM_SUPPORT_JSP_AND_FACES_EL, INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT));
621
622 if (TOMAHAWK_AVAILABLE)
623 {
624 myfacesConfig.setDetectJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_DETECT_JAVASCRIPT,
625 INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT));
626 myfacesConfig.setAutoScroll(getBooleanInitParameter(extCtx, INIT_PARAM_AUTO_SCROLL,
627 INIT_PARAM_AUTO_SCROLL_DEFAULT));
628
629 myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
630 INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
631 myfacesConfig.setResourceVirtualPath(getStringInitParameter(extCtx, INIT_PARAM_RESOURCE_VIRTUAL_PATH,
632 INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT));
633
634 myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
635 INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652 }
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669 return myfacesConfig;
670 }
671
672 private static boolean getBooleanInitParameter(ExternalContext externalContext,
673 String paramName,
674 boolean defaultValue)
675 {
676 String strValue = externalContext.getInitParameter(paramName);
677 if (strValue == null)
678 {
679
680
681 return defaultValue;
682 }
683 else if (strValue.equalsIgnoreCase("true") || strValue.equalsIgnoreCase("on") ||
684 strValue.equalsIgnoreCase("yes"))
685 {
686 return true;
687 }
688 else if (strValue.equalsIgnoreCase("false") || strValue.equalsIgnoreCase("off") ||
689 strValue.equalsIgnoreCase("no"))
690 {
691 return false;
692 }
693 else
694 {
695
696
697 return defaultValue;
698 }
699 }
700
701 private static String getStringInitParameter(ExternalContext externalContext,
702 String paramName,
703 String defaultValue)
704 {
705 String strValue = externalContext.getInitParameter(paramName);
706 if (strValue == null)
707 {
708
709
710
711 return defaultValue;
712 }
713
714 return strValue;
715 }
716
717 private static long getLongInitParameter(ExternalContext externalContext,
718 String paramName,
719 long defaultValue)
720 {
721 String strValue = externalContext.getInitParameter(paramName);
722 if (strValue == null)
723 {
724
725
726 return defaultValue;
727 }
728 else
729 {
730 try
731 {
732 return Long.parseLong(strValue);
733 }
734 catch (NumberFormatException e)
735 {
736
737
738 }
739 return defaultValue;
740 }
741 }
742
743 private void setResourceVirtualPath( String resourceVirtualPath )
744 {
745 this._resourceVirtualPath = resourceVirtualPath;
746 }
747
748 public String getResourceVirtualPath()
749 {
750 return this._resourceVirtualPath;
751 }
752
753 public boolean isPrettyHtml()
754 {
755 return _prettyHtml;
756 }
757
758 private void setPrettyHtml(boolean prettyHtml)
759 {
760 _prettyHtml = prettyHtml;
761 }
762
763 public boolean isDetectJavascript()
764 {
765 return _detectJavascript;
766 }
767
768 private void setDetectJavascript(boolean detectJavascript)
769 {
770 _detectJavascript = detectJavascript;
771 }
772
773 private void setReadonlyAsDisabledForSelect(boolean readonlyAsDisabledForSelect)
774 {
775 _readonlyAsDisabledForSelect = readonlyAsDisabledForSelect;
776 }
777
778 public boolean isReadonlyAsDisabledForSelect()
779 {
780 return _readonlyAsDisabledForSelect;
781 }
782
783
784 public long getConfigRefreshPeriod()
785 {
786 return _configRefreshPeriod;
787 }
788
789 public void setConfigRefreshPeriod(long configRefreshPeriod)
790 {
791 _configRefreshPeriod = configRefreshPeriod;
792 }
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807 public boolean isRenderViewStateId()
808 {
809 return _renderViewStateId;
810 }
811
812 public void setRenderViewStateId(boolean renderViewStateId)
813 {
814 _renderViewStateId = renderViewStateId;
815 }
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831 public boolean isStrictXhtmlLinks()
832 {
833 return _strictXhtmlLinks;
834 }
835
836 public void setStrictXhtmlLinks(boolean strictXhtmlLinks)
837 {
838 _strictXhtmlLinks = strictXhtmlLinks;
839 }
840
841 public boolean isTomahawkAvailable()
842 {
843 return TOMAHAWK_AVAILABLE;
844 }
845
846 public boolean isMyfacesImplAvailable()
847 {
848 return MYFACES_IMPL_AVAILABLE;
849 }
850
851 public boolean isRiImplAvailable()
852 {
853 return RI_IMPL_AVAILABLE;
854 }
855
856
857
858
859
860
861 public boolean isAllowJavascript()
862 {
863 return _allowJavascript;
864 }
865
866 private void setAllowJavascript(boolean allowJavascript)
867 {
868 _allowJavascript = allowJavascript;
869 }
870
871 public boolean isAutoScroll()
872 {
873 return _autoScroll;
874 }
875
876 private void setAutoScroll(boolean autoScroll)
877 {
878 _autoScroll = autoScroll;
879 }
880
881 private void setAddResourceClass(String addResourceClass)
882 {
883 _addResourceClass = addResourceClass;
884 }
885
886 public String getAddResourceClass()
887 {
888 return _addResourceClass;
889 }
890
891
892
893
894
895 public static String getAddResourceClassFromServletContext(ServletContext servletContext)
896 {
897 String addResourceClass = servletContext.getInitParameter(INIT_PARAM_ADD_RESOURCE_CLASS);
898
899 return addResourceClass == null ? INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT : addResourceClass;
900 }
901
902
903
904
905 public boolean isCheckExtensionsFilter()
906 {
907 return _checkExtensionsFilter;
908 }
909
910 public void setCheckExtensionsFilter(boolean extensionsFilter)
911 {
912 _checkExtensionsFilter = extensionsFilter;
913 }
914
915
916
917
918 public boolean isViewStateJavascript()
919 {
920 return _viewStateJavascript;
921 }
922
923 private void setViewStateJavascript(boolean viewStateJavascript)
924 {
925 _viewStateJavascript = viewStateJavascript;
926 }
927
928 public void setRenderClearJavascriptOnButton(
929 boolean renderClearJavascriptOnButton)
930 {
931 _renderClearJavascriptOnButton = renderClearJavascriptOnButton;
932 }
933
934
935
936
937
938
939
940
941
942 public boolean isRenderClearJavascriptOnButton()
943 {
944 return _renderClearJavascriptOnButton;
945 }
946
947 public boolean isRenderHiddenFieldsForLinkParams()
948 {
949 return renderHiddenFieldsForLinkParams;
950 }
951
952 public void setRenderHiddenFieldsForLinkParams(
953 boolean renderHiddenFieldsForLinkParams)
954 {
955 this.renderHiddenFieldsForLinkParams = renderHiddenFieldsForLinkParams;
956 }
957
958 public void setSaveFormSubmitLinkIE(boolean saveFormSubmitLinkIE)
959 {
960 _saveFormSubmitLinkIE = saveFormSubmitLinkIE;
961 }
962
963
964
965
966
967
968
969 public boolean isSaveFormSubmitLinkIE()
970 {
971 return _saveFormSubmitLinkIE;
972 }
973
974 public String getDelegateFacesServlet()
975 {
976 return _delegateFacesServlet;
977 }
978
979 public void setDelegateFacesServlet(String delegateFacesServlet)
980 {
981 _delegateFacesServlet = delegateFacesServlet;
982 }
983
984 public boolean isRefreshTransientBuildOnPSS()
985 {
986 return _refreshTransientBuildOnPSS;
987 }
988
989 public void setRefreshTransientBuildOnPSS(boolean refreshTransientBuildOnPSS)
990 {
991 this._refreshTransientBuildOnPSS = refreshTransientBuildOnPSS;
992 }
993
994 public boolean isRefreshTransientBuildOnPSSAuto()
995 {
996 return _refreshTransientBuildOnPSSAuto;
997 }
998
999 public void setRefreshTransientBuildOnPSSAuto(
1000 boolean refreshTransientBuildOnPSSAuto)
1001 {
1002 this._refreshTransientBuildOnPSSAuto = refreshTransientBuildOnPSSAuto;
1003 }
1004
1005 public boolean isRefreshTransientBuildOnPSSPreserveState()
1006 {
1007 return refreshTransientBuildOnPSSPreserveState;
1008 }
1009
1010 public void setRefreshTransientBuildOnPSSPreserveState(
1011 boolean refreshTransientBuildOnPSSPreserveState)
1012 {
1013 this.refreshTransientBuildOnPSSPreserveState = refreshTransientBuildOnPSSPreserveState;
1014 }
1015
1016 public boolean isValidateXML()
1017 {
1018 return _validateXML;
1019 }
1020
1021 public void setValidateXML(boolean validateXML)
1022 {
1023 _validateXML = validateXML;
1024 }
1025
1026 public boolean isWrapScriptContentWithXmlCommentTag()
1027 {
1028 return _wrapScriptContentWithXmlCommentTag;
1029 }
1030
1031 public void setWrapScriptContentWithXmlCommentTag(
1032 boolean wrapScriptContentWithXmlCommentTag)
1033 {
1034 this._wrapScriptContentWithXmlCommentTag = wrapScriptContentWithXmlCommentTag;
1035 }
1036
1037 public boolean isRenderFormSubmitScriptInline()
1038 {
1039 return _renderFormSubmitScriptInline;
1040 }
1041
1042 public void setRenderFormSubmitScriptInline(
1043 boolean renderFormSubmitScriptInline)
1044 {
1045 _renderFormSubmitScriptInline = renderFormSubmitScriptInline;
1046 }
1047
1048 public boolean isDebugPhaseListenerEnabled()
1049 {
1050 return _debugPhaseListenerEnabled;
1051 }
1052
1053 public void setDebugPhaseListenerEnabled(boolean debugPhaseListener)
1054 {
1055 this._debugPhaseListenerEnabled = debugPhaseListener;
1056 }
1057
1058 public boolean isStrictJsf2RefreshTargetAjax()
1059 {
1060 return _strictJsf2RefreshTargetAjax;
1061 }
1062
1063 public void setStrictJsf2RefreshTargetAjax(boolean strictJsf2RefreshTargetAjax)
1064 {
1065 this._strictJsf2RefreshTargetAjax = strictJsf2RefreshTargetAjax;
1066 }
1067
1068 public boolean isStrictJsf2CCELResolver()
1069 {
1070 return _strictJsf2CCELResolver;
1071 }
1072
1073 public void setStrictJsf2CCELResolver(boolean strictJsf2CCELResolver)
1074 {
1075 this._strictJsf2CCELResolver = strictJsf2CCELResolver;
1076 }
1077
1078 public String getDefaultResponseWriterContentTypeMode()
1079 {
1080 return _defaultResponseWriterContentTypeMode;
1081 }
1082
1083 public void setDefaultResponseWriterContentTypeMode(
1084 String defaultResponseWriterContentTypeMode)
1085 {
1086 this._defaultResponseWriterContentTypeMode = defaultResponseWriterContentTypeMode;
1087 }
1088
1089 public boolean isViewUniqueIdsCacheEnabled()
1090 {
1091 return _viewUniqueIdsCacheEnabled;
1092 }
1093
1094 public void setViewUniqueIdsCacheEnabled(boolean viewUniqueIdsCacheEnabled)
1095 {
1096 _viewUniqueIdsCacheEnabled = viewUniqueIdsCacheEnabled;
1097 }
1098
1099 public boolean isSupportJSPAndFacesEL()
1100 {
1101 return _supportJSPAndFacesEL;
1102 }
1103
1104 public void setSupportJSPAndFacesEL(
1105 boolean supportJSPANDFacesEL)
1106 {
1107 _supportJSPAndFacesEL = supportJSPANDFacesEL;
1108 }
1109
1110 public int getComponentUniqueIdsCacheSize()
1111 {
1112 return _componentUniqueIdsCacheSize;
1113 }
1114
1115 public void setComponentUniqueIdsCacheSize(int componentUniqueIdsCacheSize)
1116 {
1117 this._componentUniqueIdsCacheSize = componentUniqueIdsCacheSize;
1118 }
1119 }