← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2047: Extended StreamActionSupport to optionally disallow caching. Fixed issue with caching of gis images

 

------------------------------------------------------------
revno: 2047
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Fri 2010-09-03 13:09:50 +0200
message:
  Extended StreamActionSupport to optionally disallow caching. Fixed issue with caching of gis images
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.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/util/StreamActionSupport.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java	2010-09-03 11:09:50 +0000
@@ -69,7 +69,12 @@
         
         if ( getFilename() != null )
         {
-            response.addHeader( "Content-disposition", "filename=\"" + getFilename() + "\"" );
+            response.addHeader( "Content-Disposition", "attachment; filename=\"" + getFilename() + "\"" );
+        }
+        
+        if ( disallowCache() )
+        {
+            response.addHeader( "Cache-Control", "no-cache" );
         }
         
         try
@@ -94,4 +99,9 @@
     protected abstract String getContentType();
     
     protected abstract String getFilename();
+    
+    protected boolean disallowCache()
+    {
+        return false;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java	2010-09-03 09:19:46 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java	2010-09-03 11:09:50 +0000
@@ -151,13 +151,13 @@
         
         if ( svg == null || title == null || indicator == null || period == null || width == null || height == null )
         {
-            log.info( "Export map form session" );
+            log.info( "Export map from session" );
 
             svgDocument = (SVGDocument) SessionUtils.getSessionVar( SVGDOCUMENT );
         }
         else
         {
-            log.info( "Export map form request" );
+            log.info( "Export map from request" );
 
             Period _period = periodService.getPeriod( period );
 
@@ -195,4 +195,10 @@
     {
         return "dhis2_gis.png";
     }
+    
+    @Override
+    protected boolean disallowCache()
+    {
+        return true;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-03 09:31:54 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-03 11:09:50 +0000
@@ -621,7 +621,7 @@
 						var svgDivId = null;
 
 						for ( i=0; i<svgChildren.length; i++ ) { // Search for div containing SVG
-							var svgDivId = svgChildren[i].getAttribute('id');
+							svgDivId = svgChildren[i].getAttribute('id');
 							if ( svgDivId && svgDivId.indexOf( 'OpenLayers.Layer.Vector_' ) != -1 ) {
 								break;
 							}