Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

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 a javax.servlet.http.Part object.

  • required: This is a Boolean value. If it is true, 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...