As the JSF standard does not say anything about uploading files from a JSF page, every component set library offers its own solution for this, and so does Trinidad. Handling file uploads involves some extra steps, which are described in this section. As in the Tomahawk chapter, we are going to add a photo upload facility to the edit kid form as an example.
File uploading depends on the Trinidad filter. So before you continue, make sure you have configured this correctly, as described in the Setting up Trinidad section at the beginning of this chapter.
We also have to make sure that the XHTML form that is generated as a part of our page accepts files for upload. This means that the enctype
attribute of the XHTML<form>
tag has to have the multipart/form-data
value. If we are using a standard<h:form>
component to render the<form>
tag, we should set these values. However, as we’re using a<tr:form>
tag in our application, we can...