springnewbie
Sep 12th, 2007, 09:37 PM
I have to download a jasper report in CSV format and I have done the following configuration as mentioned below. The issue is once is click on save/cancel button of download window the popup window behind does not closes.
On the server side I set content-disposition header as attachment; filename=report.csv.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="jsReportViewResolver" class="org.springframework.web.servlet.view.BeanNameViewR esolver">
<property name="order"><value type="java.lang.Integer">0</value></property>
</bean>
<bean id="jasperReportsHtmlView" class="com.company.cc.reports.view.SortableJasperReportsH tmlView">
<property name="exporterClassName"><value>net.sf.jasperreports.engine.export.JRHtmlExporter</value></property>
<property name="useWriter"><value type="boolean">true</value></property>
<property name="contentType"><value>text/html</value></property>
<property name="outputType"><value>html</value></property>
</bean>
<bean id="jasperReportsPdfView" class="com.company.cc.reports.view.JasperReportsSingleFor matView">
<property name="exporterClassName"><value>net.sf.jasperreports.engine.export.JRPdfExporter</value></property>
<property name="useWriter"><value type="boolean">false</value></property>
<property name="contentType"><value>application/pdf</value></property>
<property name="outputType"><value>pdf</value></property>
</bean>
<bean id="jasperReportsCsvView" class="com.company.cc.reports.view.JasperReportsSingleFor matView">
<property name="exporterClassName"><value>com.company.cc.reports.export.CustomCsvExporter</value></property>
<property name="useWriter"><value type="boolean">true</value></property>
<property name="contentType"><value>text/csv</value></property>
<property name="outputType"><value>csv</value></property>
</bean>
<bean id="jasperReportsXlsView" class="com.company.cc.reports.view.JasperReportsSingleFor matView">
<property name="exporterClassName"><value>com.company.cc.reports.CustomXlsExporter</value></property>
<property name="useWriter"><value type="boolean">false</value></property>
<property name="contentType"><value>application/vnd.ms-excel</value></property>
<property name="outputType"><value>xls</value></property>
</bean>
<bean id="baseReportView"
class="com.company.cc.reports.CustomJasperReportsMultiFor matView" abstract="true">
<property name="jdbcDataSource"><ref bean="dataSource"/></property>
<property name="reportDataKey"><value>someInfo</value></property>
<property name="url"><value>/WEB-INF/jasperreports/someReport.jasper</value></property>
<property name="formatMappings">
<map>
<entry key="html"><ref local="jasperReportsHtmlView"/></entry>
<entry key="pdf"><ref local="jasperReportsPdfView"/></entry>
<entry key="csv"><ref local="jasperReportsCsvView"/></entry>
<entry key="xls"><ref local="jasperReportsXlsView"/></entry>
</map>
</property>
<property name="exporterParameters">
<map>
<entry key="net.sf.jasperreports.engine.export.JRXlsExporterPa rameter.IS_WHITE_PAGE_BACKGROUND">
<value type="boolean">true</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRXlsExporterPa rameter.IS_ONE_PAGE_PER_SHEET">
<value type="boolean">true</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterP arameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS">
<value type="boolean">true</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterP arameter.IS_USING_IMAGES_TO_ALIGN">
<value type="boolean">false</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterP arameter.HTML_HEADER">
<value>
<![CDATA[
<html>
<head>
<!-- HTTP 1.1 -->
<meta http-equiv="Cache-Control" content="no-store"/>
<!-- HTTP 1.0 -->
<meta http-equiv="Pragma" content="no-cache"/>
<!-- Prevents caching at the Proxy Server -->
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Content-Type" content="text/html" charset=utf-8"/>
]]>
</value>
</entry>
</map>
</property>
<property name="contentDispositionMappings">
<props>
<prop key="html">inline; filename=report.html</prop>
<prop key="csv">attachment; filename=report.csv</prop>
<prop key="pdf">inline; filename=report.pdf</prop>
<prop key="xls">inline; filename=report.xls</prop>
</props>
</property>
</bean>
<bean id="ReportView" parent="baseReportView">
<property name="subReportUrls">
<map>
<entry key="subreport1">
<value>/WEB-INF/jasperreports/Tank.jasper</value>
</entry>
</map>
</property>
</bean>
</beans>
please let me know if there is any solution for closing the background window. I am testing this on IE
On the server side I set content-disposition header as attachment; filename=report.csv.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="jsReportViewResolver" class="org.springframework.web.servlet.view.BeanNameViewR esolver">
<property name="order"><value type="java.lang.Integer">0</value></property>
</bean>
<bean id="jasperReportsHtmlView" class="com.company.cc.reports.view.SortableJasperReportsH tmlView">
<property name="exporterClassName"><value>net.sf.jasperreports.engine.export.JRHtmlExporter</value></property>
<property name="useWriter"><value type="boolean">true</value></property>
<property name="contentType"><value>text/html</value></property>
<property name="outputType"><value>html</value></property>
</bean>
<bean id="jasperReportsPdfView" class="com.company.cc.reports.view.JasperReportsSingleFor matView">
<property name="exporterClassName"><value>net.sf.jasperreports.engine.export.JRPdfExporter</value></property>
<property name="useWriter"><value type="boolean">false</value></property>
<property name="contentType"><value>application/pdf</value></property>
<property name="outputType"><value>pdf</value></property>
</bean>
<bean id="jasperReportsCsvView" class="com.company.cc.reports.view.JasperReportsSingleFor matView">
<property name="exporterClassName"><value>com.company.cc.reports.export.CustomCsvExporter</value></property>
<property name="useWriter"><value type="boolean">true</value></property>
<property name="contentType"><value>text/csv</value></property>
<property name="outputType"><value>csv</value></property>
</bean>
<bean id="jasperReportsXlsView" class="com.company.cc.reports.view.JasperReportsSingleFor matView">
<property name="exporterClassName"><value>com.company.cc.reports.CustomXlsExporter</value></property>
<property name="useWriter"><value type="boolean">false</value></property>
<property name="contentType"><value>application/vnd.ms-excel</value></property>
<property name="outputType"><value>xls</value></property>
</bean>
<bean id="baseReportView"
class="com.company.cc.reports.CustomJasperReportsMultiFor matView" abstract="true">
<property name="jdbcDataSource"><ref bean="dataSource"/></property>
<property name="reportDataKey"><value>someInfo</value></property>
<property name="url"><value>/WEB-INF/jasperreports/someReport.jasper</value></property>
<property name="formatMappings">
<map>
<entry key="html"><ref local="jasperReportsHtmlView"/></entry>
<entry key="pdf"><ref local="jasperReportsPdfView"/></entry>
<entry key="csv"><ref local="jasperReportsCsvView"/></entry>
<entry key="xls"><ref local="jasperReportsXlsView"/></entry>
</map>
</property>
<property name="exporterParameters">
<map>
<entry key="net.sf.jasperreports.engine.export.JRXlsExporterPa rameter.IS_WHITE_PAGE_BACKGROUND">
<value type="boolean">true</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRXlsExporterPa rameter.IS_ONE_PAGE_PER_SHEET">
<value type="boolean">true</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterP arameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS">
<value type="boolean">true</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterP arameter.IS_USING_IMAGES_TO_ALIGN">
<value type="boolean">false</value>
</entry>
<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterP arameter.HTML_HEADER">
<value>
<![CDATA[
<html>
<head>
<!-- HTTP 1.1 -->
<meta http-equiv="Cache-Control" content="no-store"/>
<!-- HTTP 1.0 -->
<meta http-equiv="Pragma" content="no-cache"/>
<!-- Prevents caching at the Proxy Server -->
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Content-Type" content="text/html" charset=utf-8"/>
]]>
</value>
</entry>
</map>
</property>
<property name="contentDispositionMappings">
<props>
<prop key="html">inline; filename=report.html</prop>
<prop key="csv">attachment; filename=report.csv</prop>
<prop key="pdf">inline; filename=report.pdf</prop>
<prop key="xls">inline; filename=report.xls</prop>
</props>
</property>
</bean>
<bean id="ReportView" parent="baseReportView">
<property name="subReportUrls">
<map>
<entry key="subreport1">
<value>/WEB-INF/jasperreports/Tank.jasper</value>
</entry>
</map>
</property>
</bean>
</beans>
please let me know if there is any solution for closing the background window. I am testing this on IE