OAF Download Blob File Table Column OAF Download Blob Table Table Column 1)Cretae custom table to store blob column. CREATE TABLE xx_ile_blobs ! ile_id "#TE$ER %Attac&ed_ile_#ame 'ARC(AR!*+) %Attac&ed_ile BLOB %ContentT,-e 'ARC(AR!*+) %creation_date DATE %created_b, #/BER %last_u-date_date DAT DATE E %last_u-dated_b, "#TE$ER %last_u-date_lo0in "#TE$ER ) )"n 2De3elo-er Create EO%'O and A/ based on abo3e table. 4)Create #ew 5a0e . Add A/ to t&e t&e -a0e. 6) Create new re0ion inside -a0e wit& re0ion st,le ad3ancedT ad3ancedTable able *) Deine 'iew 'iew instance 7xFileBlo 7xFileBlobs'O189:ourTa bs'O189:ourTable'O1; ble'O1; on ad3anced ad3ancedTa Table ble <) Create Column inside ad3Table ad3Table or FileId FileId.. Add sortable &eader and s-eci, 5rom-t File Id or Id or it. Add item to added Column. -date 'iew Attribute as FileId FileId or or item.
=) Create Column inside ad3Table ad3Table or AttachedFile AttachedFile.. Add sortable &eader and s-eci, 5rom-tAttachedFile 5rom-t AttachedFile or it. Add item to added Column. Assi0n "d e0. AttachedFile "tem >t,le messageDownload File /"/E T,-e 88'iew Attribute w&ic& is -ic?ed rom table Contenttype column Data T,-e BLOB 'iew Attribute as AttachedFileName 88 T&is will be name on (,-erlin?.
Page 1 of 9
File 'iew Attribute 5rom-t
AttachedFile File
#ote @ -load Attac&ment button na3i0ates to -load 5a0e. !For "normation onl,)
For more information Page 35 Of OA Framewor! De"eloper #$ide
Declarati"e Implementation 5erorm t&e ollowin0 ste-s to im-lement t&e File Download eature declarati3el, in an OA Extension -a0e.
Page 2 of 9
>te- 1@ Create a re0ion in ,our -a0e la,out re0ion% wit& t&e Form -ro-ert, set to tr$e or t&e -a0e la,out. >te- @ "n t&e new re0ion% create an item o item st,le messageDownload. Note% " ,ou im-lement a messa0eDownload item in a table or ad3anced table re0ion% t&e 3iew obect used to render t&e table or ad3anced table must &a3e a desi0nated -rimar, ?e,% ot&erwise t&e messa0eDownload web bean will re-eatedl, download content rom t&e irst row. >te- 4@ "n t&e OA Extension 5ro-ert, "ns-ector% set t&e ollowin0 -ro-erties or t&e messa0eDownload item@
��
&iew Instance T&e 3iew obect instance o t&e underl,in0 data source.
��
&iew Attri'$te T&e 3iew attribute t&at ma-s to a column in t&e underl,in0 data source.
��
File &iew Attri'$te T&e 3iew attribute t&at ma-s to t&e column t&at stores t&e ile content.
��
File Name O"erride T&e ile name to sa3e to w&en ,ou select t&e File Download lin? and c&oose t&e >a3e o-tion in t&e File Download window to sa3e t&e ile. T&e deault ile name t&at a--ears in t&e File 4* #ame ield o t&e >a3e As dialo0 window is deri3ed rom t&e 3alue returned rom t&e 3iew attribute s-eciied b, t&e 'iew Attribute -ro-ert,. T&e 3alue o t&e File #ame O3erride -ro-ert, o3errides t&at deault ile name and is es-eciall, useul i t&e 3iew attribute returns instructional text% suc& as Clic? on t&is lin? to download t&e ile. " t&e File #ame O3erride -ro-ert, is not deined% t&en t&e ile name to sa3e to is t&e 3alue returned rom t&e 3iew attribute.
�� File (I() *ype T&e /"/E t,-e o t&e ile. >ee t&e Runtime Control exam-le below i ,ou do not want to s-eci, a static 3alue or t&is -ro-ert,.
��
Data *ype T&e data t,-e o t&e File 'iew Attribute. T&e BLOB datat,-e is su--orted or File Download. ��Prompt T&e text -rom-t t&at -roceeds t&e File Download lin?.
r
Page 3 of 9
OAF -load Blob File in Table Column OAF -load Blob Table Column 1)Create OA 5a0e. )Add A/ Den to -a0eLa,outR#. 4)Create >tac?Re0ion or an, reuired base la,out re0ion. !o-tional) 6)Add orm Re0ion wit& columns as
*)C&an0e Attac&ed File BLOB.
Page 4 of 9
a)Remo3e 'iew instance and 'iew Attribute b) Data t,-e to
<)Create controller on 5a0eLa,out R#. =)"nside A/im-l add below code im-ort oracle.bo.Row im-ort oracle.a--s.nd.ramewor?.OA'iewObect im-ort oracle.bo.Transaction
-ublic 3oid createAttac&!) OA'iewObect 3o G !OA'iewObect)0et7xFileBlobs'O1!) 88 5er t&e codin0 standards% t&is is t&e -ro-er wa, to initialiHe a 88 'O t&at is used or bot& inserts and ueries. >ee 'iew Obects 88 in Detail in t&e De3elo-erIs $uide or additional inormation. i !J3o.is5re-aredForExecution!)) 3o.executeKuer,!) Row row G 3o.createRow!) 3o.insertRow!row) 88 Reuired -er OA Framewor? /odel Codin0 >tandard /
tate!Row.>TAT>_"#"T"AL"NED) 88 end createAttac&!)
-ublic 3oid a--l,!) 0etTransaction!).commit!)
Page 5 of 9
88 end a--l,!)
)"n Controller -rocessReuest add below code im-ort oracle.a--s.nd.ramewor?.OAA--lication/odule .. OAA--lication/odule am G -a0eContext.0etA--lication/odule!webBean) am.in3o?e/et&od!createAttac&% null)
M)Add createBlobDomain met&od inside Controller. im-ort oracle.cabo.ui.data.DataObect im-ort oracle.bo.domain.BlobDomain im-ort a3a.io."n-ut>tream im-ort a3a.io.Out-ut>tream im-ort a3a.io."OExce-tion im-ort a3a.sl.>KLExce-tion .. -ri3ate BlobDomain createBlobDomain!DataObect -ile-loadData) 88 init t&e internal 3ariables "n-ut>tream in G null BlobDomain blobDomain G null Out-ut>tream out G null tr, >trin0 -File#ame G !>trin0) -ile-loadData.select'alue!null%5LOAD_F"LE_#A/E) BlobDomain u-loadedB,te>tream G !BlobDomain)-ile-loadData.select'alue!null%-File#ame) 88 $et t&e in-ut stream re-resentin0 t&e data rom t&e client in G u-loadedB,te>tream.0et"n-ut>tream!) 88 create t&e BlobDomain datat,-e to store t&e data in t&e db blobDomain G new BlobDomain!) 88 0et t&e out-ut>tream or &te BlobDomain out G blobDomain.0etBinar,Out-ut>tream!) b,te buerPQ G new b,teP1MQ or!int b,tesRead G + !b,tesRead G in.read!buer% +% 1M)) JG 1) out.write!buer% +% b,tesRead) in.close!)
Page 6 of 9
catc& !"OExce-tion e) e.-rint>tac?Trace!) catc& !>KLExce-tion e) e.ill"n>tac?Trace!) 88 return t&e illed BlobDomain return blobDomain
1+)Add below -iece o code inside -rocessForm Reuest im-ort oracle.a--s.nd.ramewor?.OA'iewObect im-ort oracle.bo.Row .. 88 >elect ile t&en &it commit i !-a0eContext.0et5arameter!CommitBtn) JG null) OA'iewObect 3o G !OA'iewObect)am.ind'iewObect!7xFileBlobs'O1) oracle.bo.domain.#umber ile"d G !oracle.bo.domain.#umber)3o.0etCurrentRow!).0etAttribute!File"d) Row row G !Row)3o.0etCurrentRow!) DataObect ile-loadData G !DataObect)-a0eContext.0et#amedDataObect!Attac&edFile)
i!ile-loadData JG null) >trin0 uFile#ame G ile"d.to>trin0!)_!>trin0) ile-loadData.select'alue!null%5LOAD_F"LE_#A/E) >trin0 contentT,-e G !>trin0)ile-loadData.select'alue!null%5LOAD_F"LE_/"/E_T:5E) row.setAttribute!Attac&edFile% createBlobDomain!ile-loadData)) row.setAttribute!Attac&edFile#ame% uFile#ame) row.setAttribute!Contentt,-e% contentT,-e) 88 File -load Ends
Page 7 of 9
am.in3o?e/et&od!a--l,) >trin0 ile#ame G !>trin0)3o.0etCurrentRow!).0etAttribute!Attac&edFile#ame) OAExce-tion conirm/essa0e G new OAExce-tion!File ile#ame u-loaded succesull, .%OAExce-tion.CO#F"R/AT"O#) -a0eContext.-utDialo0/essa0e!conirm/essa0e)
Note% :ou can set t&e -roile o-tion called 5LOAD_F"LE_>"NE_L"/"T to s-eci, t&e maximum siHe o t&e ile
a user can u-load. For exam-le% i ,ou set 5LOAD_F"LE_>"NE_L"/"T to *++S% t&en durin0 t&e &tt- 5O>T reuest% OA Framewor? reads onl, u- to *++S rom t&e stream and t&rows an exce-tion i t&e u-loaded ile is lar0er t&an *++S.
To -load File into >tandard F#D_LOB> table &tt-@88robertun0erius.word-ress.com8+118+68+8buildin0a0enericu-load-a0einoa ramewor?8
Page 8 of 9
For OAF 5a0e to -load Files into >er3er rom local /ac&ine
[email protected]?umar8entr,8oa_-a0e_to_u-load_iles &tt-@88mu?x.blo0s-ot.com8+1+8+18u-loadiletoa--licationser3erusin0.&tml &tt-@88m,stuoa.blo0s-ot.com8+18+48u-loadin0ileintoser3erromlocal.&tml HxG<1db*b+
Page 9 of 9