← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2576: Minor fix

 

------------------------------------------------------------
revno: 2576
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-01-14 20:53:47 +0100
message:
  Minor fix
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm


--
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/GridJasperResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java	2011-01-14 17:42:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java	2011-01-14 19:53:47 +0000
@@ -39,12 +39,14 @@
 import net.sf.jasperreports.engine.JasperReport;
 
 import org.amplecode.quick.StatementManager;
+import org.apache.commons.lang.StringUtils;
 import org.apache.struts2.ServletActionContext;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.system.util.CodecUtils;
 import org.hisp.dhis.system.util.StreamUtils;
 import org.hisp.dhis.util.ContextUtils;
 
@@ -60,6 +62,7 @@
     private static final String KEY_GRID = "grid";
     private static final String TEMPLATE = "grid.vm";
     private static final String RESOURCE_LOADER_NAME = "class";
+    private static final String DEFAULT_FILENAME = "Grid";
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -105,7 +108,9 @@
 
         HttpServletResponse response = ServletActionContext.getResponse();
 
-        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, null, false );
+        String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".pdf";
+        
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, false );
         
         // ---------------------------------------------------------------------
         // Write jrxml based on Velocity template

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm	2011-01-14 19:27:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm	2011-01-14 19:53:47 +0000
@@ -39,7 +39,7 @@
 				<textElement>
 					<font fontName="Ubuntu" size="12"/>
 				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[${dollar}F{organisationunitname}]]></textFieldExpression>
+				<textFieldExpression class="java.lang.String"><![CDATA[${dollar}F{param_organisationunit_name}]]></textFieldExpression>
 			</textField>
 			<staticText>
 				<reportElement x="265" y="67" width="24" height="20"/>
@@ -53,7 +53,9 @@
 					<reportElement x="12" y="114" width="532" height="210"/>
 					<chartTitle/>
 					<chartSubtitle/>
-					<chartLegend/>
+					<chartLegend>
+						<font fontName="Ubuntu"/>
+					</chartLegend>
 				</chart>
 				<categoryDataset>
 					<dataset>
@@ -72,7 +74,7 @@
 				<bar3DPlot isShowLabels="true">
 					<plot/>
 					<itemLabel color="#000000" backgroundColor="#FFFFFF">
-						<font isBold="true"/>
+						<font fontName="Ubuntu" isBold="true"/>
 					</itemLabel>
 					<categoryAxisFormat>
 						<axisFormat>
@@ -96,10 +98,8 @@
 	<columnHeader>
 		<band height="51" splitType="Stretch">
 			#set( $x = 10 )
-			#foreach( $header in $grid.getVisibleHeaders() )
-			
-			#if( $header.meta )	#set( $offset = 110 ) #else	#set( $offset = 60 ) #end
-			
+			#foreach( $header in $grid.getVisibleHeaders() )			
+			#if( $header.meta )	#set( $offset = 110 ) #else	#set( $offset = 60 ) #end			
 			<staticText>
 				<reportElement x="${x}" y="26" width="${offset}" height="20"/>
 				<textElement #if( !$header.meta )textAlignment="Center"#end>
@@ -117,10 +117,8 @@
 	<detail>
 		<band height="21" splitType="Stretch">
 			#set( $x = 10 )
-			#foreach( $header in $grid.getVisibleHeaders() )
-			
-			#if( $header.meta )	#set( $offset = 110 ) #else	#set( $offset = 60 ) #end
-			
+			#foreach( $header in $grid.getVisibleHeaders() )			
+			#if( $header.meta )	#set( $offset = 110 ) #else	#set( $offset = 60 ) #end			
 			<textField>
 				<reportElement x="${x}" y="0" width="${offset}" height="20"/>
 				<textElement #if( !$header.meta )textAlignment="Center"#end>