Advanced Application Express
Advanced Application Express
www.tusc.com/briefing
By Bradley D. Brown http://bradleydbrown.blogspot.com Chairman and Chief Architect, TUSC
Abstract
Oracle Application Express is a powerful and comprehensive tool. Numerous advanced tips and techniques will be covered in this presentation. These topics include: pop-up windows, complex searches, document management, indexing and searching, tool tip or hints, email links, page 0, help text, background jobs, add to my calendar feature, saving contacts, sending mass emails, and more.
Topics
HTML
Favorite Icon Pop-ups & pass-backs Tool tips Anchors
PL/SQL
Complex searches Function-based queries Background jobs
JavaScript
Setting focus AJAX Netflix Flyups Google Maps
Apex
Page 0 Help text / page Custom login page Scrolling text Document Management Outlook Integration Email
HTML Tips
Favorite Icon
In Page template
<link rel="shortcut icon" href="/favicon2.ico" type="image/x-icon" />
Pop-up windows
Pop-up Window
Target=_blank in Link Attributes
Anchors
Best practice in page template is to include at the top of the body section
<a name="Top">
This way you can place a return to top link anywhere on the page
<a href=#Top><img src="/i/themes/theme_8/blue_arrow_up.gif" alt=Top of page" title=Top of page"></a>
Page 0
Anything placed on Page 0 will appear on every page by default Can use Conditional display to turn region on or off for specific pages, users, etc.
Help text
Highlight Current
Key Elements
Custom Template
Hidden item used in PL/SQL expression to determine Selected row Based off of current themes alternating row report template
The Oracle Experts
You can create your own logon page for any application You can use Oracle Application Expresss built-in authentication or you can use any existing scheme you have Good document on creating a custom logon page:
http://forums.oracle.com/forums/thread.jsp?forum=137&thread =220034
Link is to p?n=document_number
select DESCRIPTION, decode(document, null, '<a href="f?p=' || :app_id || ':11:::::p11_person_id,p11_document_id:' || person_id || ',' || document_id || '">Upload Supporting Document</a>', '<a href="p?n=' || document || '">Download Document</a>') document from PERSON_DOCUMENT where person_id = :p1_id
If you
Might want to port your application Have many documents Desire to index document content
Create placeholder
CREATE TABLE TEMP_RESUMES (NAME VARCHAR2(90), BLOB_CONTENT BLOB)
Sqlldr user/pass control=docs.ctl load data infile * into table resumes fields terminated by ', (file_name char(50), blob_content lobfile(file_name) terminated by eof) BEGINDATA a.doc b.doc
LENGTH(blob_content) doc_size, 'ascii' dad_charset, '[email protected]' created_by, SYSDATE created_on, '[email protected]' updated_by, SYSDATE updated_on, SYSDATE last_updated, 'BLOB' content_type, blob_content, NULL LANGUAGE, 'Loaded by BDB in bulk' description, NULL file_type, NULL file_charset FROM TEMP_RESUMES
Loading Documents
INSERT INTO resumes(id,flow_id,name,filename,mime_type ,doc_size,dad_charset,created_by,created_o n,updated_by,updated_on,last_updated,cont ent_type,blob_content,description) SELECT id,flow_id,name,filename,mime_type,doc_size ,dad_charset,created_by,created_on,update d_by,updated_on,last_updated,content_type, blob_content,:P20_DESCRIPTION FROM APEX_APPLICATION_FILES WHERE name = :P1_FILE_NAME; DELETE from APEX_APPLICATION_FILES WHERE name = :P1_FILE_NAME;
Need a process to move document after upload See http://download.oracl e.com/docs/cd/B324 72_01/doc/appdev.3 00/b32469/up_dn_fil es.htm
The Results
Add to my Calendar
Industry standard (RFC 2445) ICS format
Mac/Apple iCalendar, Mozilla Calendar, Outlook, etc.
Add contact
Industry standard contact VCF format
Email links
Select statement
select '<a href="mailto:' || me.EMAIL_ADDRESS || '">' || first_name || ' ' || last_name || '</a>' Member
Link
Report attributes, pick attribute, link Link Text = #MEMBER# Target = URL URL = mailto:#EMAIL_ADDRESS#
end loop;
end;
PL/SQL tips
Complex searches
The Function
RSVP_FUNCTION
CREATE OR REPLACE FUNCTION rsvp_function (in_event_no number) RETURN rsvp_table where PIPELINED IS out_rec RSVP_COLUMNS := RSVP_COLUMNS(NULL,NULL,NULL,NULL,NUL L); TableSet RSVP_TABLE; from where and total cursor count_as_of_cur (in_date date) is select sum(decode(yn,'Y',1,0)) y, sum(decode(yn,'N',1,0)) n rsvp event_no = in_event_no rsvp_date <= in_date + 1; number := 0; event_no = in_event_no; select count(*) count from rsvp
cursor min_max_cur is select min(trunc(rsvp_date)) min_date, max(trunc(rsvp_date)) max_date, max(trunc(rsvp_date))min(trunc(rsvp_date)) days from where rsvp event_no = in_event_no;
cursor count_invitees_cur is
RSVP_FUNCTION
BEGIN -- Figure out the total count of invited people for count_invitees_rec in count_invitees_cur loop total := count_invitees_rec.count; end loop; for count_as_of_rec in count_as_of_cur(out_rec.rsvp_date) loop out_rec.y count_as_of_rec.y; out_rec.n count_as_of_rec.n; out_rec.w total - count_as_of_rec.y count_as_of_rec.n; end loop; for min_max_rec in min_max_cur loop FOR i IN 1 .. min_max_rec.days+1 LOOP PIPE ROW(out_rec); END LOOP; out_rec.event_no := in_event_no; END LOOP; RETURN; END; := := :=
out_rec.rsvp_date := min_max_rec.min_date + i - 1;
Columns
CREATE OR REPLACE TYPE rsvp_Columns AS OBJECT ( event_no number, rsvp_date date, y number, n number, w number);
Table
CREATE OR REPLACE TYPE RSVP_Table AS TABLE OF YPO.RSVP_COLUMNS
The Results
Background jobs
apex_plsql_job is a wrapper written around dbms_job APEX_PLSQL_JOBS is a table containing the job information for those submitted Very helpful for those hourly, daily, weekly, etc. processes
UPDATE_JOB_STATUS
Updates the status of the currently running job. Most effective when called from the submitted PL/SQL.
TIME_ELAPSED
Determines how much time has elapsed since the job was submitted.
JOBS_ARE_ENABLED
Determines whether or not the database is currently in a mode which supports submitting jobs to the APEX_PLSQL_JOB package.
PURGE_PROCESS
Cleans up submitted jobs. Submitted jobs stay in the APEX_PLSQL_JOBS view until either Oracle Oracle Application Express cleans out those records, or you call PURGE_PROCESS to manually remove them.
JavaScript
JavaScript provides clientside power Good doc to work from: http://www.oracle.com/technol ogy/products/database/htmld b/howtos/htmldb_javascript_h owto2.html#ref
Where to Place JavaScript Functions Calling JavaScript from a Button Add Client-Side JavaScript Validations Enable / Disable Form Elements Change the Value of Form Elements
Check out /i/javascript/apex_html_elements.js for a complete list of already developed JavaScript (charCount, setStyle, confirmDelete, hideShow, GetCookie, SetCookie, html_PopUp, etc) To focus on an item, make sure to change focus property in page properties first_field is a build-in function:
<script type="text/javascript"> first_field('P20_FROM_DATE'); </script>
AJAX
Asynchronous JavaScript and XML
Rest
Http get commands Returns XML
Excellent examples
http://apex.oracle.com/pls/otn/f?p =11933
Using AJAX
Asynchronous Java Script and XML
Not new technology, just combination of existing Interacts with the server without refreshing the page
Used a lot in APEX SQL workshop APEX makes implementation simple Refresh a variety of objects
Single display item Multi-value things such as select list Entire report regions
Using AJAX
Netflix Flyups
Netflix uses AJAX to retrieve its flyups. For a great thread on how to implement this, see http://forums.oracle.com/fo rums/thread.jspa?threadID =318874&tstart=0
Summary
Forum is helpful and well monitored Watch for Web 2.0 additions
Questions?
Special Thanks
Larry Linnemeyer for his advanced topics and all of his work on the Oracle Application Express book
PL/SQL New Features Forms, Reports Designer Team Management Uncommon Leaders Workflow DBA topics
Copyright Information
Neither TUSC nor the author guarantee this document to be error-free. Please provide comments/questions to [email protected]. TUSC 2007. This document cannot be reproduced without expressed written consent from an officer of TUSC.