svn commit: r1061295 - in /ofbiz/trunk/framework/birt/src/org/ofbiz/birt: BirtWorker.java webapp/view/BirtViewHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1061295 - in /ofbiz/trunk/framework/birt/src/org/ofbiz/birt: BirtWorker.java webapp/view/BirtViewHandler.java

jleroux@apache.org
Author: jleroux
Date: Thu Jan 20 13:35:00 2011
New Revision: 1061295

URL: http://svn.apache.org/viewvc?rev=1061295&view=rev
Log:
A patch from Chatree Srichart "BIRT set output file name." (https://issues.apache.org/jira/browse/OFBIZ-4129) - OFBIZ-4129

I got a request to export a BIRT report as PDF file with custom file name. I attach a patch file for this feature.

Modified:
    ofbiz/trunk/framework/birt/src/org/ofbiz/birt/BirtWorker.java
    ofbiz/trunk/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java

Modified: ofbiz/trunk/framework/birt/src/org/ofbiz/birt/BirtWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/birt/src/org/ofbiz/birt/BirtWorker.java?rev=1061295&r1=1061294&r2=1061295&view=diff
==============================================================================
--- ofbiz/trunk/framework/birt/src/org/ofbiz/birt/BirtWorker.java (original)
+++ ofbiz/trunk/framework/birt/src/org/ofbiz/birt/BirtWorker.java Thu Jan 20 13:35:00 2011
@@ -56,6 +56,7 @@ public class BirtWorker {
     public final static String BIRT_LOCALE = "birtLocale";
     public final static String BIRT_IMAGE_DIRECTORY = "birtImageDirectory";
     public final static String BIRT_CONTENT_TYPE = "birtContentType";
+    public final static String BIRT_OUTPUT_FILE_NAME = "birtOutputFileName";
 
     private static HTMLServerImageHandler imageHandler = new HTMLServerImageHandler();
 

Modified: ofbiz/trunk/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java?rev=1061295&r1=1061294&r2=1061295&view=diff
==============================================================================
--- ofbiz/trunk/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java (original)
+++ ofbiz/trunk/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java Thu Jan 20 13:35:00 2011
@@ -39,6 +39,7 @@ import org.ofbiz.base.util.GeneralExcept
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.birt.BirtWorker;
 import org.ofbiz.birt.container.BirtContainer;
 import org.ofbiz.entity.GenericEntityException;
@@ -97,6 +98,13 @@ public class BirtViewHandler implements
             if (locale == null) {
                 locale = UtilHttp.getLocale(request);
             }
+            
+            // set output file name
+            String outputFileName = (String) request.getAttribute(BirtWorker.BIRT_OUTPUT_FILE_NAME);
+            if (UtilValidate.isNotEmpty(outputFileName)) {
+                response.setHeader("Content-Disposition", "attachment; filename=" + outputFileName);
+            }
+            
             context.put(BirtWorker.BIRT_LOCALE, locale);
             String birtImageDirectory = UtilProperties.getPropertyValue("birt", "birt.html.image.directory");
             context.put(BirtWorker.BIRT_IMAGE_DIRECTORY, birtImageDirectory);