Professional Documents
Culture Documents
Karen Cannell
kcannell@integratc.com
1 www.odtug.com
About Me …(Speaker Qualifications)
Cannell
2 www.odtug.com
About You … (Audience Background)
New to APEX?
APEX Experience?
Previous Tools?
APEX Training?
Version 3.1?
Cannell
3 www.odtug.com
Session Objectives
NOT
NOTan anAPEX
Advanced
How-ToAPEXSession
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
Why an APEX Cheat Sheet?
Cannell
5 www.odtug.com
What we’ll Cover:
f?p syntax Validation
Learning from APEX APEX
Case JavaScript
Referencing Items Report tips
& . #...# V and NV Edit Link
Item Types, Positions, Defaults Embed Link in Query
Layout Control Popup Windows
Page Region Sending Mail
Region Templates Custom Authentication
Alignment References
Customizations
6
Cannell
www.odtug.com
APEX 30-second Intro
Cannell
7 www.odtug.com
Application Builder
SQL Workshop
Utilities
8
Cannell
www.odtug.com
APEX Demonstration
9 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/...
Cannell
10 www.odtug.com
http://hostname:port/pls/ape
f?p URL x/
f?p=4000:4001:<session
id>::NO:4001:FB_FLOW_ID:700
11
Cannell
www.odtug.com
f?p Part 1: Address to APEX Server
http://<hostname>:<port>/pls/apex/...
Cannell
12 www.odtug.com
f?p Part 2: F Call and P Parameter
f?p=4000:4001:<session id>::NO:4001:FB_FLOW_ID:700
Cannell
13 www.odtug.com
f?p: parameter P args
Argument Definition Usage
App Id Application identifier or alias APP_ID, APP_ALIAS
Clear Cache Clear cache for the listed page(s) Page numbers or page alias, or
APP to clear all
Cannell
15 www.odtug.com
P = string of arguments
f?p=
AppId : Page : Session : Request :
Debug : ClearCache : ItemNames : Values : PrinterFriendly
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
f?p Example – APEX URL Target
A link to the current app, page 12, the current session, no debug,
setting p12_committee_code and p12_committee_name with the
values of p10_committee_code and p10_committee_name.
Cannell
19 www.odtug.com
f?p Example – APEX URL Target
Javascript PopupURL
javascript:popupURL('f?p=&APP_ID.:46:
&APP_SESSION.::NO::P46_MEMBERID:
&P44_MEMBERID.');
Cannell
20 www.odtug.com
Learn APEX from APEX
On Install:
Renumber App
Change Alias
Inspect Only (Cannot run)
21 www.odtug.com
About CASE … APEX is picky
Cannell
22 www.odtug.com
Referencing Items – 6 ways!
:P1_ITEM
Within SQL, PL/SQL, Page Processes,
Validations, Computations
Cannell
24 www.odtug.com
Substitution
&P1_ITEM.
Use in APEX element, f?p and HTML
references
Cannell
25 www.odtug.com
Substitution Syntax - Example
Cannell
26 www.odtug.com
V and NV Functions
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-for-
v-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
Template Substitution - Example
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
What to Use When
Cannell
32 www.odtug.com
Syntax Examples
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
Item Type, Position and Default
Item Types
Position Options
User Interface Defaults
Cannell
34 www.odtug.com
Item Types –APEX defaults
Cannell
35 www.odtug.com
Some Different Item Types
File Browse
Multi Select
Shuttle
Stop/Start Table
Text Area … w/Counter, Spellcheck, HTML Editor
Cannell
36 www.odtug.com
Advanced Item Types
Cannell
37 www.odtug.com
Item Position Settings
New Line No
Field No
ColSpan 1
RowSpan 1 Cannell
38 www.odtug.com
Drag and Drop Item Layout
Cannell
39 www.odtug.com
Drag and Drop Item Interface
Cannell
40 www.odtug.com
User Interface Defaults
Cannell
41 www.odtug.com
User Interface Defaults
Cannell
42 www.odtug.com
Layout Control
Page Region
Region Templates
Cannell
43 www.odtug.com
Page Regions
Cannell
paper #447
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
paper #447
46 www.odtug.com
Forcing Alignment
Regions
Specifically set Height and Width
<table height=”400” width=”400”><tr><td>
and close with
</td></tr></table>
Cannell
47 www.odtug.com
Forcing Region Alignment
Cannell
48 www.odtug.com
49
Cannell
www.odtug.com
Forcing Item Alignment
Cannell
50 www.odtug.com
Force Item Alignment, Attributes
Text Area:
Set height, width, a scrollbar and force the data to
Uppercase
style="font-family:Arial;font-size:10px;
height:50px;width:300px;overflow:auto;"
onBlur="javascript:{this.value =
this.value.toUpperCase(); }"
Cannell
51 www.odtug.com
Customizations
Header Logo
Corporate Interface / Look-and-Feel
Cannell
52 www.odtug.com
Header Logo or Text
Cannell
53 www.odtug.com
Corporate User Interface
Yes, Is Doable
Best Reference:
Cloning your Corporate UI with HTML DB blog series
at
http://www.orablogs.com/scott/archives/001189.html
Scott Spendolini
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
To Change Default Templates
Cannell
55 www.odtug.com
Cannell
paper #447
56 www.odtug.com
Validations
APEX
JavaScript
Cannell
57 www.odtug.com
Validations - APEX
Cannell
58 www.odtug.com
Validations - JavaScript
Cannell
59 www.odtug.com
JavaScript Example - SSN
Cannell
60 www.odtug.com
JavaScript – function in Header
function SSNValidation(ssn) {
var matchArr = ssn.match(/^(\d{3})-?\d{2}-?\d{4}$/);
var numDashes = ssn.split('-').length - 1;
if (matchArr == null || numDashes == 1) {
alert('Invalid SSN. Must be 9 digits or in the form NNN-
NN-NNNN.');
msg = "does not appear to be valid";
}
else
if (parseInt(matchArr[1],10)==0) {
alert("Invalid SSN: SSN's can't start with 000.");
msg = "does not appear to be valid";
} }
Cannell
61 www.odtug.com
Reports
Edit Link
URL(f?p) in SQL Query
Interactive Reports (3.1)
Cannell
62 www.odtug.com
Report – Edit Link
Cannell
63 www.odtug.com
Embed Link in SQL Query - example
Cannell
64 www.odtug.com
Interactive Reports
Cannell
65 www.odtug.com
Action
Select Bar
Dropdown
Link to
Single Row
Page
Custom
Edit Button
(in Query,
not part of
IR)
Cannell
66 www.odtug.com
Interactive Reports - Limitations
Single Template
Customize by CSS only (no template edits)
One IR per page
Cannot be an Updateable Report
Cannell
67 www.odtug.com
Popup Options
Cannell
68 www.odtug.com
Build Custom Popup - steps
Cannell
70 www.odtug.com
Environment Settings Æ SMTP Mail Server
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
APEX_MAIL.PUSH_QUEUE(
p_smtp_hostname IN VARCHAR2 DEFAULT,
p_smtp_portno IN NUMBER DEFAULT);
APEX_MAIL.PUSH_QUEUE;
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
APEX Mail Attachments - Example
DECLARE
l_id number;
BEGIN
l_id := APEX_MAIL.SEND(
p_to => 'fred@flintstone.com',
p_from => 'barney@rubble.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment' );
FOR c1 IN (SELECT filename, blob_content, mime_type FROM
APEX_APPLICATION_FILES WHERE ID IN (123,456)) loop
--
APEX_MAIL.ADD_ATTACHMENT( p_mail_id => l_id, p_attachment =>
c1.blob_content, p_filename => c1.filename, p_mime_type =>
c1.mime_type);
END LOOP;
COMMIT;
END;
Cannell
79 www.odtug.com
Custom Authentication, cont’d
Authentication Process:
Boolean function
2 parameters: Username, Password
return authenticate_kaleidoscope_user;
NO arguments in the call!
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
APEX OTN Technology Center
http://www.oracle.com/technology/products/database/application_e
xpress/index.html
Oracle Metalink
http://metalink.oracle.com
Cannell
82 www.odtug.com
APEX Resources, cont’d
Blogs, Blogs and More Blogs …
Scott Spendolini:
http://spendolini.blogspot.com and the older http://blogs.oracle/com/scott
Carl Backstrom: http://carlback.blogspot.com
APEX Blogs …
John Scott, http://jes.blogs.shellprompt.net/
Dimitri Gielis, http://dgielis.blogspot.com/
Mark Swetz http://marcsewtz.blogspot.com/index.html
Denes Kubicek, http://deneskubicek.blogspot.com/
Dietmar Aust, http://daust.blogspot.com/
Patrick Wolf – Inside APEX. http://inside-apex.blogspot.com and the ApexLib add-on
at http://apexlib.sourceforge.net
and more blogs off of these!
Many thanks to Mike ,Joel ,Raj, David
Cannell
83 www.odtug.com
APEX Resources, cont’d
Textbooks
Oracle HTMLDB Handbook, Develop and Deploy Fast,
Secure Web Applications by Bradley Brown, Lawrence Linnemeyer,
Oracle Press, 2006.
Easy Oracle HTML-DB, Create Dynamic Web Pages with
Oracle by Michael Cunningham and Kent Crotty, Rampant Press,
2006.
Pro Application Express by John Scott, Scott
Spendolini Coming Soon!
Cannell
84 www.odtug.com
Share Your Knowledge !
Call for Articles/Reviewers
85
Cannell
www.odtug.com
Questions ?
Karen Cannell
kcannell@integratc.com
86 www.odtug.com
Thank You ~
APEX Cheat
Sheet
Karen Cannell
kcannell@integratc.com
87 www.odtug.com