在CombinedResourceHandler中排除RichFaces JS文件

时间:2014-05-23 08:17:36

标签: jsf richfaces omnifaces combinedresourcehandler

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

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

之类的参数值
<param-value>richfaces:richfaces.js, richfaces:richfaces-queue.js, richfaces:richfaces-base-component.js</param-value>

1 个答案:

答案 0 :(得分:2)

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

<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的一个严重错误。另见其他What is the JSF resource library for and how should it be used?


对于具体问题

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