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