1

是否可以CombinedResourceHandler忽略 RichFaces JS 文件?

当我让omnifaces组合所有JS文件时,包括RichFaces和Richfaces优化关闭

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

我得到以下异常

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)
    ...

但是,无论我在 context param 中输入什么org.omnifaces.COMBINED_RESOURCE_HANDLER_EXCLUDED_RESOURCES,我都无法排除任何 Richfaces 资源。我尝试了参数值,例如

<param-value>richfaces:richfaces.js, richfaces:richfaces-queue.js, richfaces:richfaces-base-component.js</param-value>
4

1 回答 1

2

您需要提供准确的资源标识符。这些不是有效的 RichFaces 资源标识符。你似乎猜到了他们。您可以在不使用时通过查看生成的 HTML 输出轻松确定它们CombinedResourceHandler。给定 的上下文路径/playground和 的 JSF 映射*.xhtml,它看起来像这样:

<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>

/javax.faces.resource/ 没有JSF 映射后的部分是资源名称。请求参数中的部分ln是资源库(但是,正如您可能观察到的,RichFaces 没有!)。资源标识符由library:name符号表示,或者只是name在没有库的情况下。

所以,这应该为你做:

<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>

请注意,不服从资源库(并在其上自制另一层)确实是 RichFaces 的严重错误。另请参阅JSF 资源库的用途是什么以及应该如何使用它?


与具体问题无关,我无法再使用 RichFaces 4.3.6 重现问题 39。随意在GitHub 上重新打开问题,以及从一个完全空白的项目开始自己重现问题所需的最少信息。

于 2014-05-23T08:53:19.287 回答