Tuesday, December 27, 2011

How to Download attachments from table using OAMessageDownloadBean

In OA Framework JDeveloper add a message Download Button 

Please Specify 
Data Type: BLOB
View Instance : DocumentsVO [Corresponding VO name]
View Attribute: FileName [File Name Column in the VO]
File View Attribute: FileData [Blob column containing the data]

Add the below lines in code to specify MIME Type
// OA Table
OATableBean tableBean =(OATableBean) webBean.findChildRecursive("AllDocumentsTable");
// message Download 
    OAMessageDownloadBean downloadBean = (OAMessageDownloadBean)tableBean.findChildRecursive("downloadFile");
    OADataBoundValueViewObject contentBoundValue = new OADataBoundValueViewObject(downloadBean,"FileContentType");
    downloadBean.setAttributeValue(FILE_CONTENT_TYPE, contentBoundValue);


Please note that there should be a primary column in the query. If there is no primary column all the rows will download a same file.

2 comments:

Anonymous said...

In which file do i need to put this ?
Should it go in the class file of extended VO ? or in the standard cotroller file of this vo ?
Thanks,
swapnil

Oracle Consultant said...

Hi,
Can you please provide me code to download the file from a table programmatically?
Thanks in advance.