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.