Question

I am trying to enable compression and packaging of my css and js files in Richfaces 4.3.3 using the inbuilt optimisation features, but nothing I try seems to have any effect and all script and CSS files are still being loaded as separate entities - I've enabled the optimisation feature in my web.xml as follows

<context-param>
    <param-name>org.richfaces.resourceOptimization.enabled</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.resourceMapping.packedStages</param-name>
    <param-value>Production</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.resourceOptimization.compressionStages</param-name>
    <param-value>Production</param-value>
</context-param>
<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>

the links on my pages are being included like so

<h:outputStylesheet name="bootstrap.css" library="css" />

or

<h:outputScript library="js" name="bootstrap-dropdown.js" />

and these files are in the WEB-INF/resources folder. I may be mistaken, but I would then expect that richfaces would detect these files and add them into the packed.css and packed.js files, but these files are still being loaded separately. One final thing to note is that I have my PROJECT_STAGE set as follows in my faces-config.xml file

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
</context-param>

Any pointers or tips anyone could give me would be greatly appreciated!

Was it helpful?

Solution

You misunderstand how it works.

org.richfaces.resourceOptimization.enabled=true

means "when you're looking for resources, load the optimized ones." It doesn't create the packed.js/packed.css, those were created when the richfaces*.jar was built.

If you want your own resources being processed take a look at the richfaces maven plugin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top