在CombinedResourceHandler中排除RichFaces JS文件 [英] Exclude RichFaces JS files in CombinedResourceHandler

查看:98
本文介绍了在CombinedResourceHandler中排除RichFaces JS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

当我让omnifaces合并所有JS文件,包括RichFaces并关闭Richfaces优化功能

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>

我收到以下异常

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资源.我尝试了参数值,例如

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>

推荐答案

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

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>

/javax.faces.resource/ JSF映射之后的部分是资源名称. ln请求参数中的部分是资源库(但是,正如您可能观察到的那样,RichFaces没有资源!).资源标识符用library:name表示法表示,或者如果没有库则仅用name表示.

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>

请注意,违反资源库(并在其上进行另一层自制)确实是RichFaces的一个严重错误.另请参见

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?

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

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.

这篇关于在CombinedResourceHandler中排除RichFaces JS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆