 |
|
Oracle Database Tips by Donald Burleson |
Creating
a Report to Display the Documents with APEX
Use the link in the developer toolbar to edit the
page. Then, create a report region on the page using the SQL Report
type. Make the Title Easy Documents and use the following for the SQL
Query.
The following will outline two ways to provide
links in a report column, which is why the FILENAME column is selected
twice. In the SQL Query, the id and FILENAME columns have been
selected, the p?n= has been concatenated with the ID, and the
htf.anchorfunction included. The
htf.anchor function will return the proper html syntax to build the
anchor tag. What you will see above are two columns being selected:
FILENAME_1 and FILENAME_2. The query syntax for the column FILENAME_1
will return the following to be displayed in the browser.
<A HREF="p?n=2860904562035412">EasyHTMLDB.pdf</A>
The second method is to modify the HTML
Expression. Edit the attributes for the report column named
FILENAME_2. Enter the following text for the HTML Expression:
<A HREF="p?n=#ID#">#FILENAME_2#</A>
Apply the changes and run the application page.
There will be two columns, FILENAME_1 and FILENAME_2, which look
exactly the same. One was done within the SQL statement and one by
modifying the HTML Expression.
There is one final method that can be used to
provide a link to download the document. That is to modify the Column
Link properties for the column. To try this, remove the text in the
HTML Expression for the FILENAME_2 column and make the following
changes to the Column Link property of the column attributes.
·
Link Text: #FILENAME_2#
·
Target: URL
·
URL: p?n=#ID#
Apply the changes and run the page to try it out.
This section has shown three methods for providing
a link to download a document. The truth is, I have not found any
compelling reasons to use one or the other. My personal preference is
to keep it out of the SQL if possible. Either way, developers now
have three ways and can choose their favorite.
Downloading a PDF into
the Browser
Although this chapter has shown how to provide
document download capability to the audience, there is also the desire
to permit a document, such as a PDF, to be downloaded directly into
the browser. This is a common way to provide online documents to
users and is much like what can be obtained from the Oracle web site.
This feature is also provided for by APEX and
is as simple as adding another parameter in the call to the P
procedure in the URL. To make the change for the HTML Expression
method described above, change the text to the following:
<A HREF="p?n=#ID#&p_inline=YES">#FILENAME_2#</A>
To do the same thing using the Column Link method
described above, change the URL text to the following:
p?n=#ID#&p_inline=YES
Now clicking on the link EasyHTMLDB.pdf will
display the document directly in the browser. The Back button will
return to the running application page.
The above book excerpt is from:
Easy HTML-DB
Oracle Application Express
Create
Dynamic Web Pages with OAE
ISBN 0-9761573-1-4
Michael Cunningham & Kent Crotty
http://www.rampant-books.com/book_2005_2_html_db.htm |