Sei sulla pagina 1di 9

OAF Download Blob File Table Column

OAF Download Blob Table Column


1)Cretae custom table to store blob column.
CREATE TABLE xx_file_blobs
(
file_id INTEGER
,Attached_file_Name VARCHAR2(50)
,Attached_file BLOB
,ContentType VARCHAR2(50)
,creation_date DATE
,created_by NUMBER
,last_update_date DATE
,last_updated_by INTEGER
,last_update_login INTEGER
);
2)In JDeveloper Create EO,VO and AM based on above table.
3)Create New Page . Add AM to the page.
4) Create new region inside page with region style advancedTable
5) Define View instance XxFileBlobsVO1/<YourTableVO1> on advancedTable
6) Create Column inside advTable for FileId. Add sortable header and specify Prompt File
Id for it.
Add item to added Column. Update View Attribute as FileId for item.

7) Create Column inside advTable for AttachedFile. Add sortable header and specify
PromptAttachedFile for it.
Add item to added Column. Assign
Id
eg. AttachedFile
Item Style
messageDownload
File MIME Type
Contenttype
//View Attribute which is picked from table
column
Data Type
BLOB
View Attribute as
AttachedFileName
// This will be name on Hyperlink.

Page 1 of 9

File View Attribute


Prompt

AttachedFile
File

Note :-- Upload Attachment button navigates to Upload Page. (For Inofrmation only)

For more information


Page 350 Of OA Framework Developer Guide

Declarative Implementation
Perform the following steps to implement the File Download feature declaratively in an
OA Extension page.

Page 2 of 9

Step 1: Create a region in your page layout region, with the


Form property set to true for the page layout.
Step 2: In the new region, create an item of item style
messageDownload.
Note:
If you implement a messageDownload item in a table or advanced table region, the view
object used to
render the table or advanced table must have a designated primary key, otherwise the
messageDownload web
bean will repeatedly download content from the first row.
Step 3: In the OA Extension Property Inspector, set the following properties for the
messageDownload item:

View Instance - The view object instance of the underlying data source.

View Attribute - The view attribute that maps to a column in the underlying data source.

File View Attribute - The view attribute that maps to the column that stores the file
content.

File Name Override - The file name to save to when you select the File Download link
and choose the
Save option in the File Download window to save the file. The default file name that appears
in the File
352
Name field of the Save As dialog window is derived from the value returned from the view
attribute
specified by the View Attribute property. The value of the File Name Override property
overrides that
default file name and is especially useful if the view attribute returns instructional text, such
as "Click on
this link to download the file". If the File Name Override property is not defined, then the file
name to
save to is the value returned from the view attribute.

File MIME Type - The MIME type of the file. See the Runtime Control example below if
you do not want
to specify a static value for this property.

Data Type - The data type of the File View Attribute. The BLOB datatype is supported
for File
Download.
Prompt - The text prompt that proceeds the File Download link.
r

Page 3 of 9

OAF Upload Blob File in Table Column


OAF Upload Blob Table Column
1)Create OA Page.
2)Add AM Defn to pageLayoutRN.
3)Create StackRegion or any required base layout region. (optional)
4)Add form Region with columns as

5)Change Attached File


BLOB.

Page 4 of 9

a)Remove View instance and View Attribute b) Data type to

6)Create controller on PageLayout RN.


7)Inside AMimpl add below code
**********************************************************
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.jbo.Transaction;
public void createAttach()
{
OAViewObject vo = (OAViewObject)getXxFileBlobsVO1();
// Per the coding standards, this is the proper way to initialize a
// VO that is used for both inserts and queries. See View Objects
// in Detail in the Developer's Guide for additional information.
if (!vo.isPreparedForExecution())
{
vo.executeQuery();
}
Row row = vo.createRow();
vo.insertRow(row);
// Required per OA Framework Model Coding Standard M69
row.setNewRowState(Row.STATUS_INITIALIZED);
} // end createAttach()
public void apply()
{
getTransaction().commit();
Page 5 of 9

} // end apply()
**********************************************************

8)In Controller processRequest add below code


**********************************************************
import oracle.apps.fnd.framework.OAApplicationModule;
..
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("createAttach", null);
**********************************************************

9)Add createBlobDomain method inside Controller.


**********************************************************
import oracle.cabo.ui.data.DataObject;
import oracle.jbo.domain.BlobDomain;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.sql.SQLException;
..
private BlobDomain createBlobDomain(DataObject pfileUploadData)
{
// init the internal variables
InputStream in = null;
BlobDomain blobDomain = null;
OutputStream out = null;
try
{
String pFileName =
(String) pfileUploadData.selectValue(null,"UPLOAD_FILE_NAME");
BlobDomain uploadedByteStream =
(BlobDomain)pfileUploadData.selectValue(null,pFileName);
// Get the input stream representing the data from the client
in = uploadedByteStream.getInputStream();
// create the BlobDomain datatype to store the data in the db
blobDomain = new BlobDomain();
// get the outputStream for hte BlobDomain
out = blobDomain.getBinaryOutputStream();
byte buffer[] = new byte[8192];
for(int bytesRead = 0; (bytesRead = in.read(buffer, 0, 8192)) != -1;)
out.write(buffer, 0, bytesRead);
in.close();
Page 6 of 9

}
catch (IOException e)
{
e.printStackTrace();
}
catch (SQLException e)
{
e.fillInStackTrace();
}
// return the filled BlobDomain
return blobDomain;
}
**********************************************************

10)Add below piece of code inside processForm Request


**********************************************************
import oracle.apps.fnd.framework.OAViewObject;
import oracle.jbo.Row;
..
// Select file then hit commit
if (pageContext.getParameter("CommitBtn") != null)
{
OAViewObject vo = (OAViewObject)am.findViewObject("XxFileBlobsVO1");
oracle.jbo.domain.Number fileId =
(oracle.jbo.domain.Number)vo.getCurrentRow().getAttribute("FileId");
Row row = (Row)vo.getCurrentRow();
DataObject fileUploadData =
(DataObject)pageContext.getNamedDataObject("AttachedFile");

if(fileUploadData != null)
{
String uFileName =
fileId.toString()+"_"+(String)
fileUploadData.selectValue(null,"UPLOAD_FILE_NAME");
String contentType =
(String)fileUploadData.selectValue(null,"UPLOAD_FILE_MIME_TYPE");
row.setAttribute("AttachedFile", createBlobDomain(fileUploadData));
row.setAttribute("AttachedFileName", uFileName);
row.setAttribute("Contenttype", contentType);
}
// File Upload Ends
Page 7 of 9

am.invokeMethod("apply");
String fileName = (String)vo.getCurrentRow().getAttribute("AttachedFileName");
OAException confirmMessage = new OAException("File "+fileName+" uploaded
succesfully .",OAException.CONFIRMATION);
pageContext.putDialogMessage(confirmMessage);
}
**********************************************************

Note:
You can set the profile option called UPLOAD_FILE_SIZE_LIMIT to specify the maximum size
of the file

a user can upload. For example, if you set UPLOAD_FILE_SIZE_LIMIT to 500K, then
during the http POST
request, OA Framework reads only up to 500K from the stream and throws an exception if
the uploaded file is
larger than 500K.

To Upload File into Standard FND_LOBS table


http://robertjungerius.wordpress.com/2011/04/08/building-a-generic-upload-page-in-oaframework/

Page 8 of 9

For
OAF Page to Upload Files into Server from local Machine

https://blogs.oracle.com/prajkumar/entry/oaf_page_to_upload_files
http://mukx.blogspot.com/2010/01/upload-file-to-application-server-using.html
http://mystuffoaf.blogspot.com/2012/03/uploading-file-into-server-from-local.html?
zx=61db5b806994d831

Page 9 of 9

Potrebbero piacerti anche