Resources (library) in JSF 2.0
来源:互联网 发布:java网上商城源码下载 编辑:程序博客网 时间:2024/05/22 07:59
In JSF 2.0, all your web resources files like css, images or JavaScript, should put in “resources
” folder, under the root of your web application (same folder level with “WEB-INF
“).
The sub-folder under “resources
” folder is consider as “library” or “project theme“, later you can reference those “resources
” with library attribute. This new JSF resources management mechanism is really useful, it allow developer to change the web resources easily by “theme/library
” or “versioning
”.
See below examples :
Figure 1-0 : Example of a JSF2 project folder structure.
1. Normal Example
Here are some examples using “resources
” and “library” in JSF 2.0.
Include CSS file – h:outputStylesheet
<h:outputStylesheet library="theme1" name="css/style.css" />
HTML output…
<link type="text/css" rel="stylesheet" href="/JavaServerFaces/faces/javax.faces.resource/css/style.css?ln=theme1" />
Display images – h:graphicImage
<h:graphicImage library="theme1" name="img/sofa.png" />
HTML output…
<img src="/JavaServerFaces/faces/javax.faces.resource/img/sofa.png?ln=theme1" />
Include JavaScript – h:outputScript
<h:outputScript library="theme1" name="js/hello.js" />
HTML output…
<script type="text/javascript" src="/JavaServerFaces/faces/javax.faces.resource/js/hello.js?ln=theme1">
2. Versioning Example
Refer to Figure 1-0, create a “version” folder matching regex \d+(_\d+)* under “library
” folder, and the default JSF ResourceHandler will always get the highest version to display.
P.S Assume your project is Figure 1-0 structure
Include CSS file - h:outputStylesheet
<h:outputStylesheet library="default" name="css/style.css" />
Since “default” theme contains version “1_0” and “2_0”, JSF will always get the resources from the highest version, and append the version at the end of the resource.
See HTML output :
<link type="text/css" rel="stylesheet" href="/JavaServerFaces/faces/javax.faces.resource/css/style.css?ln=default&v=2_0" />
Version is optional
The version folder is optional, if you don’t have versioning, just omit it, like “newTheme” in Figure 1-0.
- Resources (library) in JSF 2.0
- JSF 2.0 新特性预览系列(Part 2.2): Resources
- Implicit Navigation in JSF 2.0
- iOS Library With Resources
- iOS Library With Resources
- iOS Library With Resources
- zz - transcript of Defining and Using Shared Resources in a Custom Control Library
- Configure Managed Beans in JSF 2.0
- Injecting Managed beans in JSF 2.0
- Conditional Navigation Rule in JSF 2.0
- Conditional Navigation Rule in JSF 2.0
- JSF-Spring integration library 发布
- JSF-Spring integration library 发布
- JSF-Spring integration library 发布
- JSF-Spring integration library 发布
- JSF-Spring integration library 发布
- C# Plug-in resources
- Resources in Visual Tracking
- poj 1845
- 后缀数组学习笔记
- linux和openwrt下更新源
- 命名规则
- 使用 XMLNS:APP 出现 ERROR 的问题
- Resources (library) in JSF 2.0
- 输入3个字符串,按字符串由短到长的顺序输出
- c递归实现 汉诺塔
- UVA 题目1223 - Editor(后缀数组求出现次数超过两次的最长子串的长度)
- VMware11.0.0安装(图解)
- Hadoop(二)——分布式集群搭建
- OC语言 关于description的探讨
- Graph Coloring( DP优化的求最大团模板题:求原图的最大独立集和输出集合元素可转化为求补图的最大团顶点数+输出最大团元素)
- CentOS PPTP配置FreeRADIUS+DaloRADIUS实现高级用户控制+流量控制