Search code examples
jsfrichfacesomnifacescombinedresourcehandler

Omnifaces: Using CombinedResourceHandler with Richfaces


when using CombinedResourceHandler in a Richfaces application only stylesheets and user defiend scripts are combined. The standard JavaScript resource and all Richfaces specific resources remain as seperated resources.

The Omnifaces documentation states:

RichFaces has the same problem with several JS files, but this is so far not exactly trivial to workaround

So my question is what this 'non-trivial workaround' would be?

As far as I can see, CombinedResourceHandler wont handle resources when getRendererType() returns org.richfaces.renderkit.ResourceLibraryRenderer. These are then handled by org.richfaces.renderkit.html.ResourceLibraryRenderer.

I am not sure what would be the best way to combine RichFaces behaviour with OmniFaces here.


Solution

  • I was able to create a solution by modifying OmniFaces CombinedResourceHandler.

    Details in short:

    Richfaces utilizes a concept called ResourceLibrarys wich means a resource may not only be a single file but instead a collection of those files. For example, RichFaces uses a resource named base-component.reslib. RichFaces ResourceHandler interpretes this resource dependency as dependency to

    • javax.faces:jsf.js
    • jquery.js
    • richfaces.js
    • richfaces-base-component.js

    So the CombinedResourceHandler needed some extra functionality to seperate dependencies to ordinary Resources from Richfaces ResourceLibraries. The latter needed to be resolved according to specifications obtained from RichFaces sources.