Is it preferable to use JSF's h:outputScript
or h:outputStylesheet
when script
/style
elements may just work for you ? What advantages does former offer over the latter ?
Asked
Active
Viewed 1,262 times
5

BalusC
- 1,082,665
- 372
- 3,610
- 3,555

Rajat Gupta
- 25,853
- 63
- 179
- 294
2 Answers
4
The JSF builtin resource handling has at least the following advantages:
- Resource versioning
- Configurable cache control
- Packaging in JAR
- Programmatic (component based) manipulation
- Automatic prepending of right context path
- EL support in CSS files
- i18n support (different resource files based on user's locale)
- Automatic HTTP/2 push (JSF 2.3+ on HTTPS only)
See also:
-
thanks for all the relevant links.. I want to clarify one thing though.. I make use of omnifaces `CombinedResourceHandler`. Would configuring cache setting using context-param `org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES` actually work ? – Rajat Gupta Sep 18 '13 at 11:39
2
Normal script/styles work if you know exactly under which context url the application is deployed.
So if you want to deploy the application under another context url you have to change your jsf code if you use script/style instead of h:outputScript and h:outputStylesheet.

René Link
- 48,224
- 13
- 108
- 140