01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.dwrp;
17:
18: import java.io.IOException;
19: import java.io.PrintWriter;
20:
21: import org.directwebremoting.extend.EnginePrivate;
22: import org.directwebremoting.util.MimeConstants;
23:
24: /**
25: * A version of the Plain Javascript Marshaller that uses iframe syntax
26: * @author Joe Walker [joe at getahead dot ltd dot uk]
27: */
28: public class HtmlCallMarshaller extends BaseCallMarshaller {
29: /* (non-Javadoc)
30: * @see org.directwebremoting.dwrp.BaseCallMarshaller#getOutboundMimeType()
31: */
32: @Override
33: protected String getOutboundMimeType() {
34: return MimeConstants.MIME_HTML;
35: }
36:
37: /* (non-Javadoc)
38: * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendOutboundScriptPrefix(java.io.PrintWriter, java.lang.String)
39: */
40: @Override
41: protected void sendOutboundScriptPrefix(PrintWriter out,
42: String batchId) throws IOException {
43: synchronized (out) {
44: out.println("<html><body><script type='text/javascript'>");
45: out.println(EnginePrivate.remoteBeginIFrameResponse(
46: batchId, true));
47: }
48: }
49:
50: /* (non-Javadoc)
51: * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendOutboundScriptSuffix(java.io.PrintWriter, java.lang.String)
52: */
53: @Override
54: protected void sendOutboundScriptSuffix(PrintWriter out,
55: String batchId) throws IOException {
56: synchronized (out) {
57: out.println(EnginePrivate.remoteEndIFrameResponse(batchId,
58: true));
59: out.println("</script></body></html>");
60: }
61: }
62:
63: /* (non-Javadoc)
64: * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendScript(java.io.PrintWriter, java.lang.String)
65: */
66: @Override
67: protected void sendScript(PrintWriter out, String script)
68: throws IOException {
69: synchronized (out) {
70: out.println(EnginePrivate.remoteEval(script));
71: }
72: }
73: }
|