Externalize Static resourses
victorio2008 Jun 10, 2013 11:04 AMHi guys,
I'm working on a web application with Richfaces 4.3.1 and jsf 2.1.21.
I try to load static resources (Css, JS and images) from external location (Content Delivery Network).On richfaces documentation, it mentioned that resource mapping is controlled by two configurations:
- mapped resources location (indicated by the red color)
- resource mapping configuration file (indicated by the blue color)
on the web.xml i added the following lines:
web.xml |
---|
<servlet> <servlet-name>Resource Servlet</servlet-name> <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Resource Servlet</servlet-name> <url-pattern>/org.richfaces.resources/*</url-pattern> </servlet-mapping> <context-param> <param-name>org.richfaces.resourceMapping.location</param-name> <param-value>#{facesContext.externalContext.requestContextPath}/rfRes/#{resourceLocation}</param-value> </context-param>
<!-- <context-param> <param-name>org.richfaces.staticResourceLocation</param-name> <param-value>META-INF/richfaces/static-resource-mappings.properties</param-value> </context-param> -->
<context-param> <param-name>org.richfaces.resourceMapping.mappingFile</param-name> <param-value>META-INF/richfaces/static-resource-mappings.properties</param-value> </context-param>
<!-- Enabling resource Optimization --> <context-param> <param-name>org.richfaces.resourceOptimization.enabled</param-name> <param-value>true</param-value> </context-param> |
On the mapper file static-resource-mappings.properties, i tried to map an image resource like a-down.gif :
static-resource-mappings.properties |
---|
imageStatic=/image/a-down.gif |
finally i referenced my resource on myPage.xhtml as following :
myPage.xhtml |
---|
<h:graphicImage id="showToolbarImg" value="imageStatic" rendered="#{iconBar.hideButton}" |
Unfortunately, it's not working .
I hope somone can help me on this one becasuse it is really puzzeling me.
My packaged directory structure should like following :
Thanks.