← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1779: Fixed bug, export to excel for report table not working

 

------------------------------------------------------------
revno: 1779
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Tue 2010-04-13 13:48:30 +0200
message:
  Fixed bug, export to excel for report table not working
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java	2010-04-13 11:48:30 +0000
@@ -27,21 +27,20 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.servlet.http.HttpServletResponse;
 
 import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.util.StreamActionSupport;
 import org.hisp.dhis.workbook.WorkbookService;
 
-import com.opensymphony.xwork2.Action;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
 public class GenerateTableDataWorkbookAction
-    implements Action
+    extends StreamActionSupport
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -73,35 +72,27 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private InputStream inputStream;
-
-    public InputStream getInputStream()
-    {
-        return inputStream;
-    }
-
-    private String fileName;
-
-    public String getFileName()
-    {
-        return fileName;
-    }
-
-    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-    public String execute()
+    @Override
+    protected String execute( HttpServletResponse response, OutputStream out )
+        throws Exception
     {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        workbookService.writeReportTableData( out, id, format );
         
-        fileName = workbookService.writeReportTableData( out, id, format );
-
-        inputStream = new ByteArrayInputStream( out.toByteArray() );
-                
         return SUCCESS;
     }
+
+    @Override
+    protected String getContentType()
+    {
+        return CONTENT_TYPE_EXCEL;
+    }
+
+    @Override
+    protected String getFilename()
+    {
+        return "ReportTable.xls";
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-03-22 14:55:54 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-04-13 11:48:30 +0000
@@ -244,12 +244,7 @@
     </action>
     
     <action name="generateTableDataWorkbook" class="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction">
-      <result name="success" type="stream">
-        <param name="contentType">application/vnd.ms-excel</param>
-        <param name="inputName">inputStream</param>
-        <param name="contentDisposition">filename="${fileName}"</param>
-        <param name="bufferSize">10240</param>
-      </result>
+      <result name="success" type="outputStreamResult"/>
     </action>
     
     <action name="getTableData" class="org.hisp.dhis.reporting.tablecreator.action.GetTableDataAction">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2010-03-11 13:21:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2010-04-13 11:48:30 +0000
@@ -365,7 +365,7 @@
            }
            else
            {
-               window.location.href = "generateTableDataWorkbook.action?id=" + id;
+               window.location.href = url;
            }
        } );
 }