Monday, April 6, 2015

File Uploading and Downloading in Oracle ADF

In this post we are going to learn very basic requirement of File Handling i.e. Uploading & Downloading in ADF it need very often to store files in absolute server path and download from there.Here are some steps that we have to follow:
  • Here, create a simple table in Data base to store uploaded file name,path and content type.
CREATE TABLE "UPLOAD_DOWNLOAD" ( "FILE_NAME" VARCHAR2(500), "PATH" VARCHAR2(500), "CONTENT_TYPE" VARCHAR2(500), CONSTRAINT "UPLOAD_DOWNLOAD_PK" PRIMARY KEY ("FILE_NAME") ENABLE )
  • Now create entity object and view object using Upload_Download table.
  • Go to view controller and create a jspx page.
  • Now drop  af:inputFile from the component palette as.
  • Then create a valueChangeListener on af:inputFile component to upload file to an actual path on server, and after upload a row is inserted in table to keep record of uploaded files.

  • Create a bean class "UploadBean" on valueChangeListener and then create a method "uploadAction" with in the bean class.

  • Now, from Data controls drop Upload_Download table on jspx as
  •  Write down this code under valueChangeListener method.

                            ValueChangeListener to exicute all method:

                         Bean method to upload file:


  • Now,create impl class of Application Module to insert record in the table for uploaded file.

                        AMimpl method to insert record in table:

  • Now,go to Client interface of AM and shuttle the method to right side as,     
  • And also add the binding of this method in jspx page as,


  • Set partial trigger on Table & auto submit on af:inputfile.
  • Now Upload part is complete here , for download functionality added a link in table column and dropped an af:fileDownloadActionListener inside link and set properties for DownloadActionListener.

                            Code for Download Listener:

  • Here, pathBind is a binding variable which is used to get the path of the file which we will download.so create its binding as,
  • save & run jspx page.

THANK YOU :)

10 comments:

  1. very helpful and explained very nicely....
    thanks quickADF and keep up the good work....!!

    ReplyDelete
  2. Hey nice work..!! Just the way beginners want it to be demonstrated..
    Thanks and keep blogging further..!!

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Nice blog very understandable thanks

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. very nice, I w looked to many others but this is the best, thansk

    ReplyDelete
  7. Thanks, i tried it but when downloaded the file are corrupted ?? please tell me what's wrong with my filestore or....

    ReplyDelete
  8. Very helpful and clear to understand. Thanks

    ReplyDelete
  9. My spouse and I love your blog and find almost all of your posts to be just what I’m looking for. Appreciating the persistence you put into your blog and the detailed information you provide. I found another one blog like you Oracle ADF.Actually I was looking for the same information on internet for Oracle Application Development Framework and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete