18.6. iText の設定
ドキュメントを生成すること自体には追加で設定を行う必要はありませんが、若干の設定を加えることでアプリケーションはより使いやすくなります。
デフォルト実装では汎用 URL
/seam-doc.seam から PDF ドキュメントを提供します。 たとえば、 多くのユーザーは /myDocument.pdf などのように実際の PDF 名と拡張子を含んでいる URL が表示されるのを好みます。完全な名前のファイルを提供するには、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>DOCUMENT_TYPE</url-pattern>
</servlet-mapping>
DOCUMENT_TYPE には以下の値を指定できます。
*.pdf*.xls*.csv
複数のドキュメントタイプを含めるには、必要な各ドキュメントタイプに対して
<servlet-name> および <url-pattern> サブ要素とともに <servlet-mapping> 要素を追加します。
use-extensions オプションは、生成されるドキュメントタイプに正しいファイル名拡張子を付けて URL を生成するよう DocumentStore コンポーネントに指示します。
<components xmlns="http://jboss.com/products/seam/components"
xmlns:document="http://jboss.com/products/seam/document"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://jboss.com/products/seam/document
http://jboss.com/products/seam/document-2.2.xsd
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-2.2.xsd">
<document:document-store use-extensions="true"/>
</components>
DocumentStore は対話スコープにドキュメントを保持するため、 対話が終了するとドキュメントの有効期限が切れます。 この時点でドキュメントへの参照は無効になります。
documentStore の error-page プロパティを編集することで、ドキュメントが存在しない場合にデフォルトのビューが表示されるよう指定します。
<document:document-store use-extensions="true"
error-page="/documentMissing.seam" />