<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=robmoore" rel="nofollow">Rob Moore</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-605?redirect=false" rel="nofollow">SPR-605</a></strong> and commented</p>
<p dir="auto">I needed to provide a single view which can output multiple export types (pdf, xls, etc). In the process of implementing a solution, I came up with something that may seem like a hack in some respects, but at least provides food for thought.</p>
<p dir="auto">I've found some shortcomings to the current classes. I attempt to address these as well (which probably belong in another ticket...):</p>
<ol dir="auto">
<li>
<p dir="auto">Need additional information required for Internet Explorer to properly handle content types. See <a href="http://www.lowagie.com/iText/faq.html#msie" rel="nofollow">http://www.lowagie.com/iText/faq.html#msie</a>.</p>
</li>
<li>
<p dir="auto">Need ability to specify report parameters.</p>
</li>
<li>
<p dir="auto">Need to support for JRDataSourceProvider. This is a useful addition for those using JasperAssistant.</p>
</li>
<li>
<p dir="auto">Need ability to specify content disposition on response (in part due to issue 1).</p>
</li>
</ol>
<p dir="auto">I attempt to resolve views by using the report name and the extension of the type I want to export. So views take the form of &lt;view-name&gt;.&lt;extension&gt; (that's the hackish part of this solution). So, for example, to resolve a view called myReport and export it to PDF, I pass in the view name "myReport.pdf."</p>
<p dir="auto">I define the various view components using a parameters class that contains the unique aspects of each view-export type. See JasperReportsViewParameters for info.</p>
<p dir="auto">I have attempted to use as much of the existing Jasper classes as possible, but I have had to override AbstractJasperReportsView extensively.</p>
<p dir="auto">Here is the snippet from my *-servlet.xml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;jasperReportsViewResolver&quot; class=&quot;jasper.JasperReportsViewResolver&quot;&gt;
    &lt;property name=&quot;order&quot;&gt;
        &lt;value&gt;1&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;prefix&quot;&gt;
        &lt;value&gt;/WEB-INF/jasper/&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;suffix&quot;&gt;
        &lt;value&gt;.jasper&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;reportDataKey&quot;&gt;
        &lt;value&gt;reportDataSource&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;exporterParameters&quot;&gt;
        &lt;map&gt;
            &lt;entry key=&quot;net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI&quot;&gt;
                &lt;value&gt;../../images/spacer.gif?&lt;/value&gt;
            &lt;/entry&gt;
            &lt;entry key=&quot;net.sf.jasperreports.engine.export.JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET&quot;&gt;
                &lt;bean id=&quot;java.lang.Boolean.TRUE&quot; class=&quot;org.springframework.beans.factory.config.FieldRetrievingFactoryBean&quot;/&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt;
    &lt;property name=&quot;contentDispositions&quot;&gt;
        &lt;props&gt;
            &lt;prop key=&quot;html&quot;&gt;inline; filename=report.html&lt;/prop&gt;
            &lt;prop key=&quot;pdf&quot;&gt;inline; filename=report.pdf&lt;/prop&gt;
            &lt;prop key=&quot;xls&quot;&gt;inline; filename=report.xls&lt;/prop&gt;
            &lt;prop key=&quot;xml&quot;&gt;inline; filename=report.xml&lt;/prop&gt;
            &lt;prop key=&quot;ser&quot;&gt;attachment; filename=report.ser&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean id="jasperReportsViewResolver" class="jasper.JasperReportsViewResolver"&gt;
    &lt;property name="order"&gt;
        &lt;value&gt;1&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="prefix"&gt;
        &lt;value&gt;/WEB-INF/jasper/&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="suffix"&gt;
        &lt;value&gt;.jasper&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="reportDataKey"&gt;
        &lt;value&gt;reportDataSource&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="exporterParameters"&gt;
        &lt;map&gt;
            &lt;entry key="net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI"&gt;
                &lt;value&gt;../../images/spacer.gif?&lt;/value&gt;
            &lt;/entry&gt;
            &lt;entry key="net.sf.jasperreports.engine.export.JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET"&gt;
                &lt;bean id="java.lang.Boolean.TRUE" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt;
    &lt;property name="contentDispositions"&gt;
        &lt;props&gt;
            &lt;prop key="html"&gt;inline; filename=report.html&lt;/prop&gt;
            &lt;prop key="pdf"&gt;inline; filename=report.pdf&lt;/prop&gt;
            &lt;prop key="xls"&gt;inline; filename=report.xls&lt;/prop&gt;
            &lt;prop key="xml"&gt;inline; filename=report.xml&lt;/prop&gt;
            &lt;prop key="ser"&gt;attachment; filename=report.ser&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
&lt;/bean&gt;
</code></pre></div>
<p dir="auto">Please feel free to contact me with questions are clarifications.</p>
<p dir="auto">Thanks,</p>
<p dir="auto">Rob</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.1.3</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10423/jasper.tar.gz" rel="nofollow">jasper.tar.gz</a> (<em>4.25 kB</em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=aleksabl" rel="nofollow">Aleksander Blomskøld</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1484?redirect=false" rel="nofollow">SPR-1484</a></strong> and commented</p>
<p dir="auto">Maven 2 POMs with dependencies is missing for Spring. It's a lot of extra job for maven 2 users to find out which dependencies Spring needs, and to have to include them manually.</p>
<hr>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/12005/buildsources.sh" rel="nofollow">buildsources.sh</a> (<em>590 bytes</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/11714/spring-maven.tgz" rel="nofollow">spring-maven.tgz</a> (<em>10.81 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/11912/spring-poms-1.2.8.zip" rel="nofollow">spring-poms-1.2.8.zip</a> (<em>22.40 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398061811" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/6209" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/6209/hovercard" href="https://github.com/spring-projects/spring-framework/issues/6209">#6209</a> maven pom hosed on repo1.maven.org (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398064554" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/6533" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/6533/hovercard" href="https://github.com/spring-projects/spring-framework/issues/6533">#6533</a> Missing m2 POMs at ibiblio.net (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">121 votes, 60 watchers</p>