1

I want to choose different facelet cache based on url like -

        if url starts with some pattern - Choose Nocache
        otherwise - Choose default cache - expiringConcurrentcache 

I am trying to override the DefaultFaceletFactory but my class is not getting triggered.

I think I need to give some configuration in faces-config.xml or web.xml but I am not sure what I am missing. I am using JSF 2.2.8.

Does anyone know what's the configuration I am missing?

public class DynamicFaceletFactory extends DefaultFaceletFactory {

    @Override
    public Facelet getFacelet(FacesContext context, URL url) throws 
                     IOException {
        if (url.getPath().contains("include://dynamicComponent/?uniqueId=")) {
            DefaultFaceletCache noCache = new DefaultFaceletCache(0); //noCache
            return noCache.getFacelet(url);
        } else {
            return super.getFacelet(context, url);
        }
    }
}
Martin54
  • 1,349
  • 2
  • 13
  • 34
visu.sandy
  • 26
  • 4
  • FaceletsFactory != FaceletsCacheFactory. Sure you don't want to override the FaceletsCacheFactory? https://stackoverflow.com/questions/31984924/custom-faceletfactory-in-jsf-2-2-alternatives-for-virtual-host-facelets – Kukeltje Sep 07 '18 at 11:06
  • I do not have access to the URL inside the FaceletCacheFactory. I am not sure how to decide the kind of cache. public class DynamicFaceletFactory extends FaceletCacheFactory { @Override public FaceletCache getFaceletCache() { // TODO Auto-generated method stub return null; } } – visu.sandy Sep 07 '18 at 13:52
  • Ok, me neither and I have no time to find out the coming days. I'm out camping with a phone but without laptop – Kukeltje Sep 07 '18 at 16:32

0 Answers0