1 16 package org.directwebremoting.dwrp; 17 18 import java.io.IOException ; 19 20 import javax.servlet.http.HttpServletResponse ; 21 22 import org.directwebremoting.ScriptBuffer; 23 import org.directwebremoting.extend.ConverterManager; 24 import org.directwebremoting.extend.EnginePrivate; 25 import org.directwebremoting.extend.MarshallException; 26 import org.directwebremoting.extend.ScriptBufferUtil; 27 import org.directwebremoting.util.MimeConstants; 28 29 33 public class HtmlScriptConduit extends BaseScriptConduit 34 { 35 42 public HtmlScriptConduit(HttpServletResponse response, String batchId, ConverterManager converterManager) throws IOException 43 { 44 super(response, batchId, converterManager); 45 } 46 47 50 protected String getOutboundMimeType() 51 { 52 return MimeConstants.MIME_HTML; 53 } 54 55 58 public void beginStream() 59 { 60 synchronized (out) 61 { 62 out.println("<html><body>"); 63 out.println("<script type=\"text/javascript\">"); 64 out.println(EnginePrivate.remoteBeginIFrameResponse(batchId, true)); 65 out.println("</script>"); 66 } 67 } 68 69 72 public void endStream() 73 { 74 synchronized (out) 75 { 76 out.println("<script type=\"text/javascript\">"); 77 out.println(EnginePrivate.remoteEndIFrameResponse(batchId, true)); 78 out.println("</script>"); 79 out.println("</body></html>"); 80 } 81 } 82 83 86 public boolean addScript(ScriptBuffer scriptBuffer) throws IOException , MarshallException 87 { 88 String script = ScriptBufferUtil.createOutput(scriptBuffer, converterManager); 89 90 synchronized (out) 91 { 92 out.println("<script type=\"text/javascript\">"); 93 out.println(ProtocolConstants.SCRIPT_START_MARKER); 94 out.println(EnginePrivate.remoteEval(script)); 95 out.println(ProtocolConstants.SCRIPT_END_MARKER); 96 out.println("</script>"); 97 98 return flush(); 99 } 100 } 101 } 102 | Popular Tags |