← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2509: The stream result now writes directly to the output/browser instead of presenting a file/attachme...

 

------------------------------------------------------------
revno: 2509
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-01-10 18:52:52 +0100
message:
  The stream result now writes directly to the output/browser instead of presenting a file/attachment. Changed the content-disposition header from attachment to inline. This is not official HTTP but is implemented in all major browsers - with slightly different behavior. This gives the nice embedded PDF viewer in Chrome a chance to display jasper reports etc directly in the browser. For firefox one can install the mozplugger package to achieve similar behaviour - this will open an embedded evince or openoffice instance for pdf/xls files.
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.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-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java	2011-01-10 17:52:52 +0000
@@ -89,7 +89,7 @@
 
         String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".csv";
         
-        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_TEXT, true, filename );
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, true, filename );
 
         // ---------------------------------------------------------------------
         // Write CSV to output stream

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2011-01-10 17:52:52 +0000
@@ -47,8 +47,8 @@
     public static final String CONTENT_TYPE_JSON = "application/json";
     public static final String CONTENT_TYPE_HTML = "text/html";
     public static final String CONTENT_TYPE_TEXT = "text/plain";
-    public static final String CONTENT_TYPE_XML = "text/xml";
-    public static final String CONTENT_TYPE_CSV = "text/csv";
+    public static final String CONTENT_TYPE_XML = "application/xml";
+    public static final String CONTENT_TYPE_CSV = "application/csv";
     public static final String CONTENT_TYPE_EXCEL = "application/vnd.ms-excel";
     
     private static final String SEPARATOR = "/";
@@ -98,7 +98,7 @@
 
         if ( filename != null )
         {
-            response.addHeader( "Content-Disposition", "attachment; filename=\"" + filename + "\"" );
+            response.addHeader( "Content-Disposition", "inline; filename=\"" + filename + "\"" );
         }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-01-06 13:33:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-01-10 17:52:52 +0000
@@ -113,5 +113,9 @@
 
 function exportReport( type )
 {
-	window.location.href = "exportTable.action?id=" + $( "#id" ).val() + "&type=" + type + "&useLast=true";
+	var url = "exportTable.action?type=" + type + "&useLast=true";
+	
+	url += $( "#id" ).length ? ( "&id=" + $( "#id" ).val() ) : "";
+	
+	window.location.href = url;
 }