You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by me...@apache.org on 2009/06/10 16:12:21 UTC

svn commit: r783366 - /incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelExportPage.java

Author: medgar
Date: Wed Jun 10 14:12:21 2009
New Revision: 783366

URL: http://svn.apache.org/viewvc?rev=783366&view=rev
Log:
set content length in response

Modified:
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelExportPage.java

Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelExportPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelExportPage.java?rev=783366&r1=783365&r2=783366&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelExportPage.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ExcelExportPage.java Wed Jun 10 14:12:21 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.click.examples.page.general;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
@@ -61,7 +62,6 @@
 
         ActionLink link = new ActionLink("export");
         link.setActionListener(new ActionListener() {
-
             public boolean onAction(Control source) {
                 export();
                 return false;
@@ -86,12 +86,21 @@
         response.setContentType(mimeType);
         response.setHeader("Pragma", "no-cache");
 
+
         OutputStream outputStream = null;
         try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            wb.write(baos);
+
+            byte[] bytes = baos.toByteArray();
+
+            response.setContentLength(bytes.length);
+
             outputStream = response.getOutputStream();
 
             // Write out Excel Workbook to response stream
-            wb.write(outputStream);
+            outputStream.write(bytes);
+            outputStream.flush();
 
             // Specify no further rendering required
             setPath(null);