Package org.primefaces.cache

Examples of org.primefaces.cache.CacheProvider


    public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
        UICache uiCache = (UICache) component;
       
        if(!uiCache.isDisabled()) {
            ResponseWriter writer = context.getResponseWriter();
            CacheProvider cacheProvider = RequestContext.getCurrentInstance().getApplicationContext().getCacheProvider();
            String key = uiCache.getKey();
            String region = uiCache.getRegion();
          
            if(key == null) {
                key = uiCache.getClientId(context);
            }
           
            if(region == null) {
                region = context.getViewRoot().getViewId();
            }
           
            String output = (String) cacheProvider.get(region, key);
            if(output == null) {
                StringWriter stringWriter = new StringWriter();
                ResponseWriter clonedWriter = writer.cloneWithWriter(stringWriter);
                context.setResponseWriter(clonedWriter);
                renderChildren(context, uiCache);
               
                output = stringWriter.getBuffer().toString();
                cacheProvider.put(region, key, output);
                context.setResponseWriter(writer);
            }
           
            writer.write(output);
        }
View Full Code Here

TOP

Related Classes of org.primefaces.cache.CacheProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.