From: Matti Tahvonen Date: Tue, 18 Jan 2011 14:09:31 +0000 (+0000) Subject: opening the server side for customized communication ( e.g. jsonp) X-Git-Tag: 6.7.0.beta1~487 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=26188682a04ba32383569f273e120ca0f99cd18a;p=vaadin-framework.git opening the server side for customized communication ( e.g. jsonp) svn changeset:16930/svn branch:6.5 --- diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 0808bd9125..40469cdef8 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -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.