1 9 package org.jboss.portal.portlet.impl; 10 11 import java.io.IOException ; 12 import java.io.OutputStream ; 13 import java.io.PrintWriter ; 14 import java.util.Locale ; 15 16 import javax.portlet.PortletURL; 17 import javax.portlet.RenderResponse; 18 19 import org.jboss.portal.portlet.PortletUtils; 20 import org.jboss.portal.server.PortalRequest; 21 import org.jboss.portal.server.PortalResponse; 22 import org.jboss.portal.server.Window; 23 import org.jboss.portal.server.WindowContext; 24 import org.jboss.portal.server.output.FragmentResult; 25 import org.jboss.portal.server.util.Properties; 26 27 31 public class RenderResponseImpl extends PortletResponseImpl implements RenderResponse 32 { 33 34 protected Window window; 35 protected PortalRequest req; 36 protected PortalResponse resp; 37 protected FragmentResult result; 38 39 public RenderResponseImpl( 40 Window window, 41 WindowContext windowCtx, 42 PortalRequest req, 43 PortalResponse resp, 44 FragmentResult result, 45 Properties properties) 46 { 47 super(req, resp, properties); 48 this.window = window; 49 this.req = req; 50 this.resp = resp; 51 this.result = result; 52 } 53 54 public void setTitle(String s) 55 { 56 result.setTitle(s); 57 } 58 59 public String getContentType() 60 { 61 return result.getContentType(); 62 } 63 64 public void setContentType(String contentType) 65 { 66 int index = contentType.indexOf(';'); 67 if (index != -1) 68 { 69 contentType = contentType.substring(0, index); 70 } 71 String responseContentType = resp.getContentType(); 72 if (!responseContentType.equals(contentType)) 73 { 74 throw new IllegalArgumentException ("Content type not accepted"); 75 } 76 result.setContentType(contentType); 77 } 78 79 public PrintWriter getWriter() throws IOException 80 { 81 return result.getWriter(); 82 } 83 84 public OutputStream getPortletOutputStream() throws IOException 85 { 86 return result.getOutputStream(); 87 } 88 89 public PortletURL createRenderURL() 90 { 91 String contentType = resp.getContentType(); 92 return PortletUtils.createRenderURL(resp, window, contentType); 93 } 94 95 public PortletURL createActionURL() 96 { 97 String contentType = resp.getContentType(); 98 return PortletUtils.createActionURL(resp, window, contentType); 99 } 100 101 public String getNamespace() 102 { 103 return "handleMetaDataEvent"; 104 } 105 106 public String getCharacterEncoding() 107 { 108 return "UTF-8"; 110 } 111 112 public Locale getLocale() 113 { 114 return req.getLocale(); 115 } 116 117 public void setBufferSize(int i) 118 { 119 } 121 122 public int getBufferSize() 123 { 124 return 0; 126 } 127 128 public void flushBuffer() throws IOException 129 { 130 } 131 132 public void resetBuffer() 133 { 134 result.resetBuffer(); 136 } 137 138 public void reset() 139 { 140 result.resetBuffer(); 142 143 properties.clear(); 145 } 146 147 public boolean isCommitted() 148 { 149 return false; 151 } 152 } 153 | Popular Tags |