JSF 2.2 upload feature
JSF developers have waited a long time for a built-in upload component. Until JSF 2.2, the workarounds consisted of using JSF extensions, such as PrimeFaces, RichFaces, and third-party libraries such as Apache Commons FileUpload.
JSF 2.2 comes with an input component dedicated for upload tasks (that renders an HTML input
element of type file
). This component is represented by the <h:inputFile>
tag and it can be used as any other JSF component. The entire list of supported attributes is available at http://docs.oracle.com/javaee/7/javaserverfaces/2.2/vdldocs/facelets/h/inputFile.html, but the most important ones are as follows:
value
: This represents the file to be uploaded as ajavax.servlet.http.Part
object.required
: This is a Boolean value. If it istrue
, the user must provide a value to submit.validator
: This indicates a validator for this component.converter
: This indicates a converter for this component.valueChangeListener
: This indicates a method that will...