cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r193119 - /cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js
Date Thu, 23 Jun 2005 09:21:50 GMT
Author: sylvain
Date: Thu Jun 23 02:21:48 2005
New Revision: 193119

URL: http://svn.apache.org/viewcvs?rev=193119&view=rev
Log:
Fix Ajax with Safari

Modified:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js?rev=193119&r1=193118&r2=193119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js Thu Jun
23 02:21:48 2005
@@ -149,10 +149,27 @@
             this.submitId = widget == null ? null : widget.getId();
             
             if (cocoon.request.getParameter("cocoon-ajax") != null) {
-                // Ask the client to load the page
+                // Ask the client to issue a new request reloading the whole page.
+                // As we have nothing special to send back, so a header is just what we need...
                 cocoon.response.setHeader("X-Cocoon-Ajax", "continue");
-                cocoon.response.setHeader("Content-Length", "0");
                 cocoon.sendStatus(200);
+                
+                // ...but Safari doesn't consider empty responses (with content-length=0)
as
+                // valid ones. So send a dummy response by using directly the HttpResponse's
+                // output stream. Avoiding this hack would require to put an additional pipeline
+                // in the sitemap for just sending this dummy response, which isn't nice.
+                var httpResponse = objectModel.get(org.apache.cocoon.environment.http.HttpEnvironment.HTTP_RESPONSE_OBJECT);
+                if (httpResponse) {
+                    httpResponse.setContentType("text/xml");
+                    var text = "<?xml version='1.0'?><bu:document xmlns:bu='" +
+                        org.apache.cocoon.transformation.BrowserUpdateTransformer.BU_NSURI
+
+                        "'></bu:document>";
+                    httpResponse.writer.print(text);
+                } else {
+                    // Empty response
+                    cocoon.response.setHeader("Content-Length", "0");
+                }
+
                 FOM_Cocoon.suicide();
             }
             



Mime
View raw message