Professional Documents
Culture Documents
Karen Cannell
kcannell@integratc.com
www.odtug.com
Cannell
3 www.odtug.com
Session Objectives
NOT an APEX How-To Session NOT an Advanced APEX Session Learn APEX syntax; Know what to use when and where Learn common tricks to customize APEX to your needs Accelerate your APEX learning curve
Cannell
4 www.odtug.com
Cannell
5 www.odtug.com
Validation
APEX JavaScript
Report tips
Edit Link Embed Link in Query
Customizations
6 www.odtug.com
Cannell
Rapid Web Development Tool Declarative Programming Wizards Wizards Wizards All Applications are HTML - no applet downloads
Cannell
7 www.odtug.com
Cannell
APEX Demonstration
www.odtug.com
f?p Syntax
URL Reference to an APEX page All APEX pages are f?p calls Two Parts:
Path to Server: http://<hostname>:<port>/apex/pls/... Call to PL/SQL Procedure F with Parameter P
/f?p=<AppId:Page:Session:Request:Debug:ClearCache: Item Name:Value(s):PrinterFriendly>
Cannell
10 www.odtug.com
f?p URL
http://hostname:port/pls/ape x/
f?p=4000:4001:<session id>::NO:4001:FB_FLOW_ID:700
11
www.odtug.com
Cannell
Cannell
12 www.odtug.com
App Id Page
Session Request Debug Clear Cache Item Name(s) Item Value(s) Printer Friendly
Session identifier HTTP page request Debug flag Clear cache for the listed page(s) Item names to pass to the page Item values to correspond to item names Printer Friendly flag
14
The actual request: GO SAVE, ADD. YES, NO or DEBUG Page numbers or page alias, or APP to clear all P1_ITEM, P2_ITEM :P1_ITEM, :P2_ITEM or &P1_ITEM. &P2_ITEM. YES, NO or PRINTER_FRIENDLY
Cannell
www.odtug.com
Cannell
15 www.odtug.com
P = string of arguments
f?p=
Cannell
16 www.odtug.com
f?p Examples
Part of a URL:
http://tunahuntress.tunahunter.com:7777/pls/apex/f?p=710:6:361726 3641284922::NO::P6_COMMITTEE_CODE:459
Translates to:
Render page 6 of application 710 for the current session, no debug, using 459 as the value of P6_COMMITTEE_CODE
Cannell
17 www.odtug.com
Cannell
18 www.odtug.com
Cannell
19 www.odtug.com
Cannell
20 www.odtug.com
21
www.odtug.com
Cannell
22 www.odtug.com
Bind Variable
:P1_ITEM Within SQL, PL/SQL, Page Processes, Validations, Computations Most frequently used
Cannell
24 www.odtug.com
Substitution
&P1_ITEM. Use in APEX element, f?p and HTML references
Cannell
25 www.odtug.com
Cannell
26 www.odtug.com
V and NV Functions
V(P1_ITEM) and NV(P1_NUMBER) Use within PL/SQL modules Current session only
Do not work in spawned/background jobs
Cannell
27 www.odtug.com
V and NV Caution
Not DETERMINISTIC Potential Performance Impact
SELECT x,y,z FROM abc WHERE x = V(P1_ITEM) Executes once for each row of abc
Wrapper for V and NV Drop-in replacement available from Inside-Apex Blog at:
http://inside-apex.blogspot.com/2006/12/drop-in-replacement-forv-and-nv.html thanks Patrick!
Cannell
28 www.odtug.com
Template Substitution
#P1_ITEM# Page, Region and Report Templates Use to customize your own templates Be aware of #...# to understand APEX templates, button, nav bar, default region placement
Cannell
29 www.odtug.com
<table class="t12FormRegion" id="#REGION_ID#" summary=""> <tr><td class="t12Header">#TITLE#</td></tr> <tr><td class="t12ButtonHolder">#CLOSE##PREVIOUS##NEXT##DELETE##EDI T##CHANGE##CREATE##HELP#</td></tr> <tr><td class="t12Body">#BODY#</td></tr> <tr><td><img src="#IMAGE_PREFIX#themes/theme_12/t.gif" width="400" Template Substitution default placement for Region height="1"></td></tr> Buttons </table>
Cannell
30 www.odtug.com
Direct
APEX_APPLICATION.G_<name> Used in PL/SQL, similar to V and NV Current session only
Do not work in spawned/background jobs
Cannell
31 www.odtug.com
Cannell
32 www.odtug.com
Syntax Examples
HTML anchor in Header, Footer or HTML Region:
<a href=f?p=&APP_ALIAS.:4:&APP_SESSION.>Click here for Page 4</a>
PL/SQL htf.anchor:
htf.anchor(f?p=||APEX_APPLICATION.G_FLOW_ID||:4:||V(APP_SESSION),Click for Page 4); or htf.anchor(f?p=||V(APP_ID)||:4:||V(APP_SESSION),Click for Page 4);
Cannell
33 www.odtug.com
Cannell
34 www.odtug.com
Cannell
35 www.odtug.com
Cannell
36 www.odtug.com
Cannell
37 www.odtug.com
Cannell
www.odtug.com
Cannell
39 www.odtug.com
Cannell
40 www.odtug.com
Cannell
41 www.odtug.com
Cannell
42 www.odtug.com
Layout Control
Page Region Region Templates Know the Defaults ... Then Know How to Adjust
Cannell
43 www.odtug.com
Page Regions
Will vary slightly from theme to theme Region Position for Sidebar Note template Substitution Strings If you dont like it Edit the Template!
Cannell
44 www.odtug.com
Region Templates
Will vary slightly from theme to theme Edit as you like
Cannell
45 www.odtug.com
Region Templates
alt. theme
Cannell
46 www.odtug.com
Forcing Alignment
Regions
Specifically set Height and Width
<table height=400 width=400><tr><td>
Cannell
47 www.odtug.com
Cannell
48 www.odtug.com
49
www.odtug.com
Cannell
Form Fields
style=width:80;
Cannell
51 www.odtug.com
Customizations
Header Logo Corporate Interface / Look-and-Feel
Cannell
52 www.odtug.com
Cannell
53 www.odtug.com
My Experience: 1 Hour to Useable, 4+ for all page templates complete with substitution tags Advice: Go for It weighing costs, of course.
Cannell
54 www.odtug.com
Cannell
55 www.odtug.com
Cannell
56 www.odtug.com
Validations
APEX JavaScript
Cannell
57 www.odtug.com
Validations - APEX
Item or Page Level NOT NULL, String Comp, Reg Exp, SQL, PL/SQL
Cannell
58 www.odtug.com
Validations - JavaScript
In HTML Form Element Attributes field
Cannell
59 www.odtug.com
Function goes in the Page Header, or, in an include file that contains all the JavaScript for the page.
Cannell
60 www.odtug.com
Reports
Edit Link URL(f?p) in SQL Query Interactive Reports (3.1)
Cannell
62 www.odtug.com
Cannell
63 www.odtug.com
Interactive Reports
Includes a Select Bar and an Action Bar Settings are Options in Report Attributes
Cannell
65 www.odtug.com
Select Dropdown
Action Bar
Cannell
66 www.odtug.com
Cannell
67 www.odtug.com
Popup Options
APEX JavaScript built-in popupURL
javascript:popupURL('f?p=&APP_ID.:46:&SESSION.:: NO::P46_MEMBERID:&P44_MEMBERID.');
Cannell
68 www.odtug.com
Sending Email
Configure Email Server Settings HTMLDB_MAIL package HMTLDB_MAIL.SEND HTMLDB_MAIL.PUSH_QUEUE
Cannell
70 www.odtug.com
Environment Settings
Cannell
71 www.odtug.com
APEX_MAIL.SEND
APEX_MAIL.SEND ( p_to IN VARCHAR2, p_from IN VARCHAR2, p_body IN VARCHAR2 | CLOB, p_body_html IN VARCHAR2 | CLOB, p_subj IN VARCHAR2 DEFAULT NULL, p_cc IN VARCHAR2 DEFAULT NULL, p_bcc IN VARCHAR2 DEFAULT NULL);
Cannell
72 www.odtug.com
APEX_MAIL.SEND - Function
v_mail_id := APEX_MAIL.SEND ( p_to IN VARCHAR2, p_from IN VARCHAR2, p_body IN VARCHAR2 | CLOB, p_body_html IN VARCHAR2 | CLOB, p_subj IN VARCHAR2 DEFAULT NULL, p_cc IN VARCHAR2 DEFAULT NULL, p_bcc IN VARCHAR2 DEFAULT NULL);
Cannell
73 www.odtug.com
APEX_MAIL - Example
DECLARE l_body_html varchar2(4000); lv_tolist varchar2( 2000) := joedba@yourcompany.com; BEGIN l_body_html := '<p> || To view matching KALEIDOSCOPE Contacts click the link: </p>'|| '<a href="http://tunahuntress.tunahunter.com:7777|| '/f?p=550:33:::::||'P33_REPORT_SEARCH:'||:P1_LAST|| '">View KALEIDOSCOPE Contacts</a></p>'; APEX_MAIL.SEND( P_TO => lv_tolist, P_FROM => :P1_EMAIL, P_BODY => l_body_html, P_BODY_HTML => l_body_html, P_SUBJ => 'New Mail Message from APEX; END;
Cannell
74 www.odtug.com
APEX_MAIL.PUSH_QUEUE
Mail Queue Sent Pushed every 10 min. PUSH_QUEUE to send immediately
APEX_MAIL.PUSH_QUEUE( p_smtp_hostname IN VARCHAR2 DEFAULT, p_smtp_portno IN NUMBER DEFAULT);
Cannell
www.odtug.com
Cannell
76 www.odtug.com
APEX_MAIL.ADD_ATTACHMENT
APEX_MAIL.ADD_ATTACHMENT( p_mail_id IN NUMBER, p_attachment IN BLOB, p_filename IN VARCHAR2, p_mime_type IN VARCHAR2);
Use function version of APEX_MAIL.SEND to return a mail id. Query filename from APEX_APPLICATION_FILES Add multiple attachments by multiple ADD_ATTACHMENT calls
Cannell
77 www.odtug.com
Cannell
www.odtug.com
Custom Authentication
Custom Authentication Wizard Most defaults are OK
Page Sentry function (here or redirect?) Session Verify function (valid session?) Invalid Session Target (where to go if failed login) Pre-Authentication (cookies? audits?) Authentication Process
Cannell
79 www.odtug.com
Cannell
80 www.odtug.com
Final Words
SAVE OFTEN Apply Changes Business Logic in Packages Export Periodically (a simple backup!)
Cannell
81 www.odtug.com
APEX Resources
APEX Forum
http://forums.oracle.com/forums/forum.jspa?forumID=137
APEX Studio
http://apex.oracle.com/i/index.html
Oracle Metalink
http://metalink.oracle.com
Cannell
82 www.odtug.com
and more blogs off of these! Many thanks to Mike ,Joel ,Raj, David
83
Cannell
www.odtug.com
Cannell
84 www.odtug.com
85
www.odtug.com
Cannell
Questions ?
APEX Cheat Sheet
KarenCannell
kcannell@integratc.com
86 www.odtug.com
Thank You ~
APEX Cheat Sheet
KarenCannell
kcannell@integratc.com
87 www.odtug.com