1

Is it possible for the CombinedResourceHandler to ignore RichFaces JS files?

When I let omnifaces combine all JS files, including RichFaces with Richfaces optimisation off

<context-param>
   <param-name>org.richfaces.resourceOptimization.enabled</param-name>
   <param-value>false</param-value>
</context-param>

I get the following exception

SEVERE: Error Rendering View[/login.xhtml]
java.lang.UnsupportedOperationException
    at org.richfaces.resource.ExternalStaticResource.getURL(ExternalStaticResource.java:90)
    at org.omnifaces.resourcehandler.CombinedResourceInfo.loadResources(CombinedResourceInfo.java:229)
    at org.omnifaces.resourcehandler.CombinedResourceInfo.getLastModified(CombinedResourceInfo.java:303)
    at org.omnifaces.resourcehandler.CombinedResource.getRequestPath(CombinedResource.java:92)
    at com.sun.faces.renderkit.html_basic.StylesheetRenderer.encodeEnd(StylesheetRenderer.java:106)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    at com.sun.faces.renderkit.html_basic.HeadRenderer.encodeHeadResources(HeadRenderer.java:105)
    at com.sun.faces.renderkit.html_basic.HeadRenderer.encodeEnd(HeadRenderer.java:92)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at com.caucho.server.webbeans.ConversationJsfViewHandler.renderView(ConversationJsfViewHandler.java:81)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.render(CodiLifecycleWrapper.java:126)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    ...

However, regardless of what I enter in the context param org.omnifaces.COMBINED_RESOURCE_HANDLER_EXCLUDED_RESOURCES, I am unable to exclude any of the Richfaces resources. I tried param values such as

<param-value>richfaces:richfaces.js, richfaces:richfaces-queue.js, richfaces:richfaces-base-component.js</param-value>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Stevanicus
  • 7,561
  • 9
  • 49
  • 70

1 Answers1

2

You need to supply the exact resource identifiers. Those aren't valid RichFaces resource identifiers. You seem to have guessed them. You can easily determine them by looking at the generated HTML output when not using CombinedResourceHandler. Given a context path of /playground and JSF mapping of *.xhtml, it'll look something like this:

<script type="text/javascript" src="/playground/javax.faces.resource/richfaces.js.xhtml"></script>
<script type="text/javascript" src="/playground/javax.faces.resource/richfaces-base-component.js.xhtml"></script>

The part after the /javax.faces.resource/ without JSF mapping is the resource name. The part in the ln request parameter is the resource library (however, as you probably observed, RichFaces has none!). The resource identifier is represented by library:name notation, or just name if there's no library.

So, this should do it for you:

<context-param>
    <param-name>org.omnifaces.COMBINED_RESOURCE_HANDLER_EXCLUDED_RESOURCES</param-name>
    <param-value>richfaces.js, richfaces-queue.js, richfaces-base-component.js</param-value>
</context-param>

Note that disobeying the resource library (and homebrewing another layer over it) is indeed a severe mistake of RichFaces. See also among others What is the JSF resource library for and how should it be used?


Unrelated to the concrete question, I can't reproduce issue 39 anymore using RichFaces 4.3.6. Feel free to reopen the issue at GitHub, along with the minimum information necessary to reproduce the problem ourselves starting with a completely blank project.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • thanks for your quick reply. I must confess I did attempt to guess the param values as nothing seemed to work, but even values without a resource identifier such as just "richfaces.js" has no effect. They always seem to be combined. – Stevanicus May 23 '14 at 10:33
  • p.s I defined the context params in web.xml – Stevanicus May 23 '14 at 10:38
  • Works for me. Have you read and understood the first part of the answer which explains how to determine them? Have you applied this information in your particular case? In any way, you'd better tell minimum information necessary to reproduce the problem ourselves starting with a completely blank project (for example, RichFaces version, etc). – BalusC May 23 '14 at 10:47
  • You were right thank you - it seemed to be a custom function that was swallowing up most of richfaces.js file. – Stevanicus May 23 '14 at 13:32
  • @BalusC Is it possible to exclude a whole library with a wildcard with `library:*.js` or something similar? – Mathieu Castets May 19 '15 at 09:40
  • 1
    @MathieuCastets: Nope, unfortunately not. Idea isn't bad tho. – BalusC May 19 '15 at 09:50