KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > dwrp > HtmlCallMarshaller


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.io.PrintWriter JavaDoc;
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 {
30     /* (non-Javadoc)
31      * @see org.directwebremoting.dwrp.BaseCallMarshaller#getOutboundMimeType()
32      */

33     protected String JavaDoc getOutboundMimeType()
34     {
35         return MimeConstants.MIME_HTML;
36     }
37
38     /* (non-Javadoc)
39      * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendOutboundScriptPrefix(java.io.PrintWriter, java.lang.String)
40      */

41     protected void sendOutboundScriptPrefix(PrintWriter JavaDoc out, String JavaDoc batchId) throws IOException JavaDoc
42     {
43         synchronized (out)
44         {
45             out.println("<html><body><script type='text/javascript'>");
46             out.println(EnginePrivate.remoteBeginIFrameResponse(batchId, true));
47         }
48     }
49
50     /* (non-Javadoc)
51      * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendOutboundScriptSuffix(java.io.PrintWriter, java.lang.String)
52      */

53     protected void sendOutboundScriptSuffix(PrintWriter JavaDoc out, String JavaDoc batchId) throws IOException JavaDoc
54     {
55         synchronized (out)
56         {
57             out.println(EnginePrivate.remoteEndIFrameResponse(batchId, true));
58             out.println("</script></body></html>");
59         }
60     }
61
62     /* (non-Javadoc)
63      * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendScript(java.io.PrintWriter, java.lang.String)
64      */

65     protected void sendScript(PrintWriter JavaDoc out, String JavaDoc script) throws IOException JavaDoc
66     {
67         synchronized (out)
68         {
69             out.println(EnginePrivate.remoteEval(script));
70         }
71     }
72 }
73
Popular Tags