3 Replies Latest reply: Apr 23, 2012 12:22 PM by dlenir RSS

Seam 2.2.2.Final (JBoss 6.1.0), DocumentStore and PDF

dlenir Newbie

Hi all,

 

I've been facing a problem for several hours... I'd just like to open a PDF generated document in new tab or window.

The document is generated by Jasperreport at the runtime.

 

The action is called in a JSF page  :

 

<h:commandLink styleClass="commandButton" id="reportButton"
                      value="View"
                      action="#{myAction.printPdfReport(_order)}" target="_blank"/>

 

 

The action code ends like this :

 

ByteArrayOutputStream output = new ByteArrayOutputStream();

JasperExportManager.exportReportToPdfStream(jasperPrint, output);

String reportId = documentStore.newId();
DocumentData data = new ByteArrayDocumentData("report" + reportId,
                    new DocumentData.DocumentType("pdf", "application/pdf"), output.toByteArray());
documentStore.saveData(reportId, data);

return "/report.pdf?docId=" + reportId;

 

 

I've configurated my seam application as it's written in the reference guide :

web.xml :

<servlet>
        <servlet-name>Document Store Servlet</servlet-name>
        <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>Document Store Servlet</servlet-name>
        <url-pattern>*.pdf</url-pattern>
</servlet-mapping>

 

 

components.xml :

<document:document-store use-extensions="true"/>

 

 

But... in the new tab I get an HTTP 404 error : ...(/myApp/report.seam/) is not available.

 

Important : this works fine with Seam 2.2.0.GA and JBoss 5.0.1.GA (but I need to upgrade to JBoss AS 6)

 

Any help will be appreciated, thanks,

 

David