Document generation works out of the box with no additional configuration needed. However, there are a few points of configuration that are needed for more serious applications.
The default implementation serves PDF documents from a generic URL, /seam-doc.seam
. Many browsers (and users) would prefer to see URLs that contain the actual PDF name like /myDocument.pdf
. This capability requires some configuration. To serve PDF files, all *.pdf resources should be mapped to the Seam Servlet Filter and to the DocumentStoreServlet:
<filter>
<filter-name>Seam Servlet Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Servlet Filter</filter-name>
<url-pattern>*.pdf</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Document Store Servlet</servlet-name>
<servlet-class>org.jboss.seam.pdf.DocumentStoreServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Document Store Servlet</servlet-name>
<url-pattern>*.pdf</url-pattern>
</servlet-mapping>
The useExtensions
option on the document store component completes the functionality by instructing the document store to generate URLs with the correct filename extension for the document type being generated.
<components xmlns="https://jboss.com/products/seam/components"
xmlns:pdf="https://jboss.com/products/seam/pdf">
<pdf:documentStore useExtensions="true" />
</components>
Generated documents are stored in conversation scope and will expire when the conversation ends. At that point, references to the document will be invalid. To You can specify a default view to be shown when a document does not exist using the errorPage
property of the documentStore.
<pdf:documentStore useExtensions="true" errorPage="/pdfMissing.seam" />