Follow by Email

Monday, 16 January 2017

Uploading mulitiple files to server path in Oracle ADF using af:inputFile

Hello All :)

Previously I have posted about uploading and downloading files from server path (Refer this post for more clarification), In that post I have described the process of uploading single file at a time but sometimes we need to upload multiple files at a time and for that requirement we can use same code with little modification

So In this post we'll see that how can we upload multiple files at a time using af:inputFile, Here I am using same sample application that is used in previous post

Default inputFile source looks like this

<af:inputFile label="Select" id="if1" valueChangeListener="#{viewScope.FileUploadDownloadBean.uploadFileVCE}"

To enable multiple files selection in af:inputFile we have to set some properties

<af:inputFile label="Select" id="if1"
autoSubmit="true" rows="5" maximumFiles="5"/>

and what rows and maximumFiles properties means ?

rowsintYesan attribute that determines the number of rows in the file list. There will be a scrollbar which will be displayed when the number of files exceeds this number.

maximumFilesintYesan attribute that is used to restrict the number of files a user can upload. If the user tries to upload more files than specified in maximumFiles then an error is returned. If maximumFiles is less than 1 then the number of files is unlimited.

After setting these properties inputFile looks like this

Now UI part is done , next is code part so to get and upload multiples files from client we have to use a List data structure and then in value change listener we'll traverse that List and upload all files to server path.

ValueChangeListener of af:inputFile- 

    /*****Generic Method to Get BindingContainer**/
    public BindingContainer getBindingsCont() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();

     * Generic Method to execute operation
     * */
    public OperationBinding executeOperation(String operation) {
        OperationBinding createParam = getBindingsCont().getOperationBinding(operation);
        return createParam;


    /**Method to Upload Multiple Files ,called on ValueChangeEvent of inputFile
     * @param vce
    public void uploadFileVCE(ValueChangeEvent vce) {
        if (vce.getNewValue() != null) {
            //Get File Object from VC Event
            List<UploadedFile> lf = (List<UploadedFile>) vce.getNewValue();

            //Traverse over file list to upload all files
            for (UploadedFile fileVal : lf) {
                //Method to check if this file is uploaded previously or not
                OperationBinding duplOb = executeOperation("checkDuplicateFile");
                duplOb.getParamsMap().put("fileNm", fileVal.getFilename());
                if (duplOb.getResult() != null && "Y".equalsIgnoreCase(duplOb.getResult().toString())) {

                    //Upload File to path- Return actual server path
                    String path = uploadFile(fileVal);
                    //Method to insert data in table to keep track of uploaded files
                    OperationBinding ob = executeOperation("setFileData");
                    ob.getParamsMap().put("name", fileVal.getFilename());
                    ob.getParamsMap().put("path", path);
                    ob.getParamsMap().put("contTyp", fileVal.getContentType());

            // Reset inputFile component after upload

AMImpl Method to check duplicate file-

    /**Method to check for duplicate files
     * @param fileNm
     * @return
    public String checkDuplicateFile(String fileNm) {
        ViewObject fileVo = this.getFileUpdDwn1();
        Row duplFile[] = fileVo.getFilteredRows("FileName", fileNm);
        if (duplFile.length > 0) {
            return "N";
        } else {
            return "Y";

For other methods and DB table refer previous post Uploading and downloading files from absolute server path
So All done for multiple files upload now run and check application

Sample ADF Application (Jdeveloper 12.1.3)- Download
Cheers :)  Happy Learning


  1. Hi Sir,

    I have a concern irrespective to this blog. Actually when i run my application on integrated weblogic in jdeveloper 12c it got deployed(run) successfully but when 2nd time when i run the same application rather then redeploying, it got undeployed. Am facing this issue on alternate basis everytime and on every machine.

    Thanks in advance.

    1. Hi Rahul

      Clean and rebuild application , delete .data folder in application directory , delete application from drs folder and check again


  2. nice work Ashish
    But i have a small problem
    when i upload *.txt or *.csv or * .jpg ...etc. i can see the file content in inlineFrame without any problems, but when i upload *.docx or *.xlsx and click on the file to see it's content i get download operation with Zip file and this zip file has the same name of the servlet

    1. Hi Mariam

      We can not directly show docx and XLS file in web page , A plugin is required to show these types and I have never implemented this
      So you can put a question in OTN Forum


  3. and when i try to download *.xlsx or *.docx the download process is working fine but i get another download file with the same name of servlet also

    1. That's because of inline frame , set render false for inline frame in case of file type is docx or xls

  4. thanks ashish
    but I have another problem
    when I apply this post in Jspx page it was working fine
    but when I try to apply it into jsff page(dynamic region with task flow)
    I got this error

    "#{bindings.dynamicRegion1.regionModel}" (that was specified for the RegionModel "value" attribute of the region component with id "r1") evaluated to null.
    This is typically due to an error in the configuration of the objects referenced by this expression.
    If it helps, the expression "#{bindings.dynamicRegion1}" evaluates to "null".
    If it helps, the expression "#{bindings}" evaluates to "null". Now using an empty RegionMode

    1. Hi Mariam

      So you have used this code in jsff page and dropped that BTF as dynamic region in a jspx page ?
      Once check that definition for region in available in pagedef or not ?