Dienstag Jul 01, 2008

t:inputFileUpload UploadedFile returns null

Today I was faced with a problem using the t:inputFileUpload control from MyFaces/Tomahawk. 

I implemented a Backing Bean with a UploadedFile Property and include the component into my existing jsf page like this:

 <t:inputFileUpload id="myUploadedFile" storage="file" immediate="false"
            value="#{workitemLobBean.uploadedFile}">
        </t:inputFileUpload>

The  problem was that in my backing bean the uploadedFile property never was set. So it was null and I was unable to get the selected file out of my form :-(

After a long time searching I found the following solution:

Do not forget to add the "enctype" attribute to your Form and set this attribute to "multipart/form-data". So your h:form tag should finally look something like this:

<h:form enctype="multipart/form-data">