ADF input file validation

af:inpitFile component does not have validation support to restrict the type of file user can upload. We need to restrict the file type either in javascript or in backing bean. In this example, I have described how to restrict certain file types in input file component. it allows only excel file formats by checking the uploaded file type is either Xls or xlsx format.

Download the ADF Input File Validation

ADF input file validation – Allows only Excel file

Created a JSF page with <af:inputFile> and <af:button> component. The value of inputText is bound with the backing bean, so we can get the file in baking bean when the submit button got clicked.Also note the property usesUpload=”true’ in <form>.

The button has actionListener and partialTrigger enabled. When the button clicked, it calls the uploadFile() method in backing bean


Below is the backing bean class which read the file extension using the regular expression and validate the file type is xls or xlsx. If the validation fails then itthrows the error message using facesMessage.



When we run the application in WebLogic, the page opens in the browser like below. I tried to upload an image file first and hits the submit button. The backing bean validates and throws an error message.

090116_0431_ADFinputfil1 ADF input file validation

When I uploaded an excel file and hit the submit button, its do nothing.

090116_0431_ADFinputfil2 ADF input file validation

govindan ADF input file validation
Connect me


Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
govindan ADF input file validation
Connect me
By | 2016-12-29T00:43:24+00:00 August 31st, 2016|Categories: ADF|Tags: , , , |1 Comment
Like us on Facebook.