]> source.dussan.org Git - vaadin-framework.git/commitdiff
opening the server side for customized communication ( e.g. jsonp)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 18 Jan 2011 14:09:31 +0000 (14:09 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 18 Jan 2011 14:09:31 +0000 (14:09 +0000)
svn changeset:16930/svn branch:6.5

src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java

index 0808bd9125411fa11d095cadf9ba24049c362c80..40469cdef827582874577429f0c8ac7b8a2f698e 100644 (file)
@@ -791,7 +791,7 @@ public abstract class AbstractCommunicationManager implements
         // Sets the response type
         response.setContentType("application/json; charset=UTF-8");
         // some dirt to prevent cross site scripting
-        outWriter.print("for(;;);[{");
+        openJsonMessage(outWriter);
 
         // security key
         Object writeSecurityTokenFlag = request
@@ -828,7 +828,7 @@ public abstract class AbstractCommunicationManager implements
                     analyzeLayouts);
 
         }
-        outWriter.print("}]");
+        closeJsonMessage(outWriter);
 
         outWriter.close();
 
@@ -1787,14 +1787,28 @@ public abstract class AbstractCommunicationManager implements
         response.setContentType("application/json; charset=UTF-8");
         final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
                 new OutputStreamWriter(out, "UTF-8")));
-        outWriter.print("for(;;);[{");
+        openJsonMessage(outWriter);
         outWriter.print("\"redirect\":{");
-        outWriter.write("\"url\":\"" + logoutUrl + "\"}}]");
+        outWriter.write("\"url\":\"" + logoutUrl + "\"}");
+        closeJsonMessage(outWriter);
         outWriter.flush();
         outWriter.close();
         out.flush();
     }
 
+    protected void closeJsonMessage(PrintWriter outWriter) {
+        outWriter.print("}]");
+    }
+
+    /**
+     * Writes the opening of JSON message to be sent to client.
+     * 
+     * @param outWriter
+     */
+    protected void openJsonMessage(PrintWriter outWriter) {
+        outWriter.print("for(;;);[{");
+    }
+
     /**
      * Gets the Paintable Id. If Paintable has debug id set it will be used
      * prefixed with "PID_S". Otherwise a sequenced ID is created.