How to override DefaultFaceletFactory in JSF 2.2.8-

98 views Asked by At

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);
        }
    }
}
0

There are 0 answers