JSF 2.2中的Custom FaceletFactory/虚拟主机facelets的替代方法 [英] Custom FaceletFactory in JSF 2.2 / Alternatives for virtual host facelets

查看:111
本文介绍了JSF 2.2中的Custom FaceletFactory/虚拟主机facelets的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自Mojarra/JSF 2.2起.无法再使用web.xml上下文参数提供自定义的FaceletFactory:

Since Mojarra/JSF 2.2. it is not possible anymore to provide a custom FaceletFactory using a web.xml context parameter:

<context-param>
        <param-name>com.sun.faces.faceletFactory</param-name>
        <param-value>my.faces.overrides.MyFaceletFactory</param-value>
</context-param>

我的应用程序提供了一些CMS功能,包括虚拟主机支持,可根据当前请求的域为不同的页面(面)提供服务.因此,http://www.domain1.com/index.xhtml返回的内容与http://www.otherdomain.com/index.xhtml不同.使用自定义资源解析器,其背后的机制没什么大不了的.这样做的真正问题在于,jsf仅根据其请求的uri来缓存facelets,该uri不包含主机名(在两种情况下均为"/index.xhtml").我通过在自定义FaceletFactory:uri = "/" + getCleanHostName() + "://" + uri;中简单地添加主机名来解决此问题.使用JSF 2.2,这似乎不再可行.还有其他方法可以在JSF 2.2中归档正确的缓存行为吗?由于其影响性能,因此不能选择禁用面部缓存.

My application provides some CMS features, including virtual host support to serve different pages (facelets) based on the currently requested domain. So http://www.domain1.com/index.xhtml returns different content than http://www.otherdomain.com/index.xhtml. The mechanics behind that are not that big of a deal using a custom resource resolver. The real problem when doing that is, that jsf caches the facelets only based on its requested uri, which does not contain the host name ("/index.xhtml" in both cases). I worked around this issue by simply adding the host name to it in my custom FaceletFactory: uri = "/" + getCleanHostName() + "://" + uri;. With JSF 2.2, this does not seem possible anymore. Is there any other way to archive the correct caching behavior in JSF 2.2? Disabling the faces cache is not an option due to its performance impact.

推荐答案

已计划按照问题611 .但是,由于存在抽象泄漏,后来又取消了它.另请参见 JSF 2.2的新增功能是什么?但是尽管有原始状态也没有回滚Ed在第611期中的要求,如下所述:

There were plans to standardize it in the JSF spec as per issue 611. However, it was cancelled later, because there were abstraction leaks. See also the What's new in JSF 2.2? But the original state was not rolled back anymore in spite of the request of Ed in issue 611 as cited below:

但是当我在r11053中删除标准化的FaceletFactory时,我没有 放回上下文参数.如果我把它放回原位并按照2.1的方式工作,您会满意吗?

But when I removed the standardized FaceletFactory, in r11053, I didn't put back the context param. Would you be satisfied if I just put it back and it worked as in 2.1?

您可能想创建一个新的问题来唤醒它.

You may want to create a new issue to wake up this.

替代方法是将其替换为自定义 ResourceHandler (不是ResourceResolver,因为这是 )以及自定义的 FaceletCacheFactory (自JSF 2.1标准化),可以通过<factory><facelet-cache-factory>faces-config.xml中注册.

The alternative is to replace it it by a custom ResourceHandler (not ResourceResolver, as that's deprecated in JSF 2.2), along with a custom FaceletCacheFactory (standardized since JSF 2.1) which can be registered via <factory><facelet-cache-factory> in faces-config.xml.

这篇关于JSF 2.2中的Custom FaceletFactory/虚拟主机facelets的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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