18.6. Configuring iText
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 DocumentStoreServlet:
<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>
The
use-extensions 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="http://jboss.org/schema/seam/components" xmlns:document="http://jboss.org/schema/seam/document" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://jboss.org/schema/seam/document http://jboss.org/schema/seam/document-2.3.xsd http://jboss.org/schema/seam/components http://jboss.org/schema/seam/components-2.3.xsd"> <document:document-store use-extensions="true"/> </components>
The document store stores documents in conversation scope, and documents will expire when the conversation ends. At that point, references to the document will be invalid. You can specify a default view to be shown when a document does not exist using the
error-page property of the documentStore.
<document:document-store use-extensions="true" error-page="/documentMissing.seam" />