Background
- /resources
- /META-INF/resources
[localePrefix/][libraryName/][libraryVersion/]resourceName[/resourceVersion]
The resource object is explained in greater detail in Ryan Lubke's "JSF 2.0 New Feature Preview Series (Part 2.3): Resources" article.#{resource['libraryName/fileName']}
/javax.faces.resource/ [?ln= ][&loc= ][&v= ]
url('/javax.faces.resource/.jsf[?ln=][&loc=][&v=')
| Parameter | Description |
| ln | The name of the library which is a sub-directory found in either the /resources or /META-INF/resources directory relative to your web application's context root. If the library is locale-specific, then the directory identified by the ln parameter will actually be a sub-directory found in a sub-directory corresponding to the two-character country-code identifying the locale. For example, say you wanted to use a graphic image (background.png) that is in the images resource library as the background for a web page. You would use the following URL: url('/javax.faces/resource/background.png.jsf?ln=images'); |
| loc | Identifies a specific local that should be used when the resource management framework returns the specified resource. If this parameter is omitted, the default locale specified by the client will be used. NOTE: The supported codes for countries are defined in the ISO 3166 standard. Continuing with the example used from the ln parameter, say you wanted to use a locale-specific background image for France. The following would be the URL used in your stylesheet. url('/javax.faces/resource/background.png.jsf?ln=images&loc=FR'); |
| v | Identifies a specific version of a resource that should be used to satisfy the resource request. If this parameter is omitted, the highest available of the identified resource will be returned. In the context of our background.png image, the CSS file would contain the following line to identify version 1.1 of the image file: url('/javax.faces/resource/background.png.jsf?ln=images&loc=FR&v=1_1'); |
Character Escaped Value ( \( ) \) , \, ' \' " \" In addition, whitespace characters should also be escaped with a backslash.
Faces Servlet Configuration Consideration
<servlet-mapping>
<servlet-name>Faces Servletservlet-name>
<url-pattern>*.jsfurl-pattern>
<url-pattern>/faces/*url-pattern>
</servlet-mapping>
Putting Everything into Action
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head id="head">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Resource Manager CSS Example</title>
</h:head>
<h:body id="body">
<h:outputStylesheet name="resourceManagerCSSExample.css"
library="resourceManagerCSSExample"
target="head" />
<p>Example of using JSF 2.0 resource management framework with CSS.</p>
</h:body>
</html>
<h:outputStylesheet name="resourceManagerCSSExample.css"
library="resourceManagerCSSExample"
target="head" />
body {
background-image: url('/javax.faces.resource/wave.png.jsf?ln=resourceManagerCSSExample');
background-repeat: no-repeat;
background-position: right top;
}
References
- Lie, HÃ¥kon Wium and Bert Bos. "6.4 URL." "Cascading Style Sheets, level 1." w3.org. 11 Apr 2008. 30 Dec 2011. <http://www.w3.org/TR/CSS1/#url>.
- Lubke, Ryan. "JSF 2.0 New Feature Preview Series (Part 2.1): Resources." Oracle.com. 15 Feb 2008. 30 Dec 2011. <http://blogs.oracle.com/rlubke/entry/jsf_2_0_new_feature5>.
- Lubke, Ryan. "JSF 2.0 New Feature Preview Series (Part 2.2): Resources." Oracle.com. 16 Feb 2008. 30 Dec 2011. <http://blogs.oracle.com/rlubke/entry/jsf_2_0_new_feature>.
- Lubke, Ryan. "JSF 2.0 New Feature Preview Series (Part 2.3): Resources." Oracle.com. 23 Jun 2008. 30 Dec 2011. <http://blogs.oracle.com/rlubke/entry/jsf_2_0_new_feature3>.
- Lubke, Ryan. "JSF 2.0 New Feature Preview Series (Part 4) Resource Re-location." Oracle.com. 25 Jun 2008. 30 Dec 2011. <http://blogs.oracle.com/rlubke/entry/jsf_2_0_new_feature4>.
- RIPE Network Coordination Centre. "ISO 3166 Codes (Countries)." fu-berlin.de. 30 Dec 2011. <http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html>.

No comments:
Post a Comment