JSF 1.1 プロジェクトでファイルをアップロードしたいと考えています。JSF 1.1 は、RichFaces ファイルのアップロードをサポートしていません。トマホークを見たけど、トマホークの使い方がわからない。誰か説明してくれませんか?
- どの JAR を使用する必要がありますか?
- そしてタグライブラリ?
- そして
web.xml
構成? - そして
faces-config.xml
構成?
または、トマホークの代替品はありますか?
JSF 1.1 プロジェクトでファイルをアップロードしたいと考えています。JSF 1.1 は、RichFaces ファイルのアップロードをサポートしていません。トマホークを見たけど、トマホークの使い方がわからない。誰か説明してくれませんか?
web.xml
構成?faces-config.xml
構成?または、トマホークの代替品はありますか?
Which JARs do I have to use?
The following ones:
I assume that you already have the JSF 1.1 JARs jsf-api
and jsf-impl
.
And taglibs?
Just the Tomahawk one, next to the two usual core/html tags:
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
And web.xml configuration?
You need the ExtensionsFilter
. This filter will take care that JSF gets the right parameters out of a multipart/form-data
request body.
<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
And faces-config.xml configuration?
Nothing special. Just create a managed bean the usual way with a UploadedFile
property which you bind to the value
attribute of <t:inputFileUpload>
.