Code example for StringWriter

Methods: getBuffer

0
         String key = cache.getKey();
         String cachedContent = (String) cache.getCacheProvider().get(cache.getRegion(), key); 
         if (cachedContent == null)
         { 
            log.debug("rendering from scratch: " + key);
            StringWriter stringWriter = new StringWriter();
            ResponseWriter cachingResponseWriter = writer.cloneWithWriter(stringWriter);
            context.setResponseWriter(cachingResponseWriter);
            renderChildren(context, component);
            context.setResponseWriter(writer);
            String output = stringWriter.getBuffer().toString();
            writer.write(output);
            cache.getCacheProvider().put(cache.getRegion(), key, output);
         } 
         else 
         { 
            log.debug("rendering from cache: " + key);
            writer.write(cachedContent);
         } 
      } 
      else