1 16 package org.apache.myfaces.wap.renderkit; 17 18 import javax.faces.render.Renderer; 19 import javax.faces.render.RenderKit; 20 21 import javax.faces.render.ResponseStateManager; 22 23 import java.util.*; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 28 36 public class WmlRenderKitImpl extends RenderKit { 37 private static Log log = LogFactory.getLog(WmlRenderKitImpl.class); 38 39 private Map renderers; 40 private ResponseStateManager rsm; 41 42 43 public WmlRenderKitImpl() { 44 log.debug("created object " + this.getClass().getName()); 45 renderers = new HashMap(); 46 rsm = new WmlResponseStateManagerImpl(); 47 } 49 50 public void addRenderer(String family, String rendererType, javax.faces.render.Renderer renderer) { 51 renderers.put(family + "." + rendererType, renderer); 52 } 53 54 public Renderer getRenderer(String family, String rendererType) { 55 log.debug("getRenderer() family:" + family + " renderType:" + rendererType); 56 Renderer renderer = (Renderer)renderers.get(family + "." + rendererType); 57 if (renderer == null){ 58 log.warn("Unsupported component-family/renderer-type: " + family + "/" + rendererType); 59 } 60 return(renderer); 61 } 62 63 public ResponseStateManager getResponseStateManager() { 64 return(rsm); 65 } 66 67 public javax.faces.context.ResponseStream createResponseStream(java.io.OutputStream outputStream) { 68 throw new UnsupportedOperationException (this.getClass().getName() + " UnsupportedOperationException"); 69 } 70 71 public javax.faces.context.ResponseWriter createResponseWriter(java.io.Writer writer, String contentTypeList, String characterEncoding) { 72 log.debug("createResponseWriter()"); 73 if (contentTypeList == null) { 74 log.info("No content type list given, creating WmlResponseWriterImpl with default content type."); 75 return new WmlResponseWriterImpl(writer, null, characterEncoding); 76 } 77 78 StringTokenizer st = new StringTokenizer(contentTypeList, ","); 79 while (st.hasMoreTokens()) { 80 String contentType = st.nextToken().trim(); 81 return new WmlResponseWriterImpl(writer, contentType, characterEncoding); 82 } 83 84 throw new IllegalArgumentException ("ContentTypeList does not contain a supported content type: " + contentTypeList); 85 } 86 87 } 88 | Popular Tags |