1
Oracle APEX 18.1 (aka 5.2)
The Golden Nuggets
Dietmar Aust
Opal-Consulting, Köln
www.opal-consulting.de
About Dietmar. 2
• Dipl.-Inform. Dietmar Aust, Freelance Consultant
• Master's Degree in Computer Science (MSCS)
• Building Oracle based Web Applications since 1997
• Portal, Forms, Reports, OWA Toolkit, now APEX!
• 1997-2000: Consultant at Oracle Germany
• Since 09/2000: Freelance Consultant, Since 2006 – APEX only!
• Author of the JasperReportsIntegration toolkit
• http://www.opal-consulting.de/tools
• 2015 Database Developer of the year in the ORDS category
3
Feature Analysis
How to find the new features? 4
https://apexea.oracle.com/
Documentation (BETA)
https://docs.oracle.com/database/apex-18.1/
Actually compute the delta
between different APEX
versions:
- APEX Dictionary
- Packages
Wie wurde analysiert? 5
How to find the new features? 6
In Debug-Mode (logged in as developer) APEX uses the
uncompressed Javascript Files (Source Code)
How to find the new features? 7
How to find the new features? 8
Pre Definition in User-Interface > Concatenated Files
18.1
Sample: Oracle APEX Page Designer, Application 4000, Page 4500
Sample application / slides available for download 9
http://dietmaraust.com/blog
10
Architecture
Additional x11-x20 … Parameters in AJAX calls 11
The big archtitecture change was in APEX 5.1 => JSON processing
Small change in 18.1: Additional Parameters for AJAX calls x11-x20
Javascript on client PL/SQL on server side
12
Application Builder
13
Application Builder
Spotlight Search
Spotlight Search 14
Powerful Search Feature (like on the Mac) to search for
• Workspace and application areas and navigates there (Packaged
Apps, SQL Workshop, Shared Components, ...)
• Applications
• Pages
• Application content
• within pages, etc.
Context dependent (Workspace, Application, Page Designer)
Spotlight Search 15
Spotlight Search 16
How to figure out the right keyboard shortcut in your language?
CTRL-’ on an English layout
… what is the representation of ‘ in a different language?
CTRL-ä on a German layout
17
Application Builder
Compatibility Mode
Compatibility Mode 18
The compatibility mode changes the behaviour of the APEX engine
at runtime
=> balancing new features /
security / stricter checks and
easy upgrades
=> No Changes in APEX 18.1
19
Application Builder
Default Schema
Default Schema 20
Pre
18.1 Set default schema for user in workspace
Default Schema 21
Pre
18.1 Default schema is used:
– SQL Workshop
– Installation of packaged applications
22
Application Builder
UT User Interface Attributes
User Interface Attributes > Collapsed by Default 23
Universal Theme starts with left navigation side collapsed
User Interface Attributes > "Built with APEX" Footer 24
Universal Theme has a new footer
Can be turned off in
User Interface Attributes
25
Application Building
26
Application Building
Social Sign-In
New Authentication Scheme 27
New Authentication Scheme
– Social Sign-In
Authentication Provider
New Authentication Scheme 28
About OAuth2 and its flow
https://developers.google.com
/identity/protocols/OAuth2
New Authentication Scheme 29
Example: Steps to authenticate with Google
1. Register oauth2 client with Google
2. Create web credentials in APEX
3. Create authentication scheme and use credentials
New Authentication Scheme 30
1. Register client with Google
Register client: https://console.developers.google.com/
New Authentication Scheme 31
New Authentication Scheme 32
2. Create web credentials in APEX
New Authentication Scheme 33
3. Create authentication scheme and use credentials
New Authentication Scheme 34
Scopes
https://developers.google.com/identity/protocols/
googlescopes#google_sign-in
Social Sign In – Requirements for https callouts 35
Requirements
• Google redirects back to official DNS domain
• Needs ACLs to call webservice (see APEX Install)
• Needs wallet for certificates
– https://blogs.oracle.com/apex/apex-https-certificates-and-
the-oracle-wallet
– https://apex.oracle.com/pls/apex/germancommunities/
apexcommunity/tipp/6121/index-en.html
• Register wallet in APEX Instance
– Manage Instance > Instance Settings > Wallet
Social Sign In – Requirements for https callouts 36
Different ways make https callouts from the database
1. Create Wallet with orapki
– https://oracle-base.com/articles/misc/utl_http-and-ssl#test-
unsecured-connection
– https://blogs.oracle.com/apex/apex-https-certificates-and-the-
oracle-wallet
2. Create Wallet using openssl
– https://blog.hazrulnizam.com/openssl-workaround-oracle-xe-
wallet/
3. Use reverse proxy:
– https://fuzziebrain.com/content/id/1711/
37
Application Building
Switching Auth Schemes
Switching Authentication Schemes at Runtime 38
Why use multiple authentication schemes at runtime?
Switching Authentication Schemes at Runtime 39
Step 1 – make apex login current scheme
Step 2 - Enable switch in session for the Google scheme
Switching Authentication Schemes at Runtime 40
Step 3 - Add button to login page and use a URL to switch
to the Google scheme
Request variable:
APEX_AUTHENTICATION=<Scheme Name>
f?p=&APP_ID.:1:&APP_SESSION.:APEX_AUTHENTICATION=Google
Switching Authentication Schemes at Runtime 41
Post Authentication Handler – change username
-- derive new username from :APP_USER
case :app_user
when '
[email protected]' then
l_new_app_user := '
[email protected]';
else
-- will not change
l_new_app_user := l_orig_app_user;
end case;
-- set user for this session
apex_custom_auth.set_user( p_user => l_new_app_user );
Switching Authentication Schemes at Runtime 42
Post Authentication Handler – get scope attributes
-- get attribute by name
apex_json.get_varchar2( p_path => 'id_token' );
apex_json.get_varchar2( p_path => 'access_token' );
-- or loop over all attributes
l_idx := apex_json.g_values.first;
while (l_idx is not null)
loop
l_value := apex_json.g_values(l_idx);
:p2_user_info := :p2_user_info ||
get_output_str( p_idx => l_idx, p_value => l_value );
l_idx := apex_json.g_values.next(l_idx);
end loop;
Switching Authentication Schemes at Runtime 43
Post Authentication Handler – make additional request
-- second request, to retrieve additional user information
c := apex_web_service.make_rest_request (
p_url => 'https://www.googleapis.com/oauth2/v3/userinfo',
p_http_method => 'GET',
p_credential_static_id => 'GOOGLE' );
apex_json.parse(c);
44
Application Building
Access Control
Application Access Control 45
Management of Roles and User / Role
Mappings as part of the application
Why?
• Convenience, almost every application
needs it
• Used for blueprint applications
Application Access Control 46
Application Access Control 47
Application Access Control 48
Security Setting to define the meaning of “ROLE”
Application Access Control 49
This makes a difference when using Authorization
Schemes
Application Access Control 50
Summary
• Roles are exported with the application
• User / Role Mappings are NOT
– Target configuration NOT overwritten
• API provided: APEX_ACL
• Data dictionary views for viewing and modifying the
data (INSERT, UPDATE, DELETE on
APEX_APPL_ACL_USERS)
51
Application Building
Application Settings
Application Settings 52
Maintain application specific configuration
settings, e.g. Environment, Email servers,
...
Why?
• Application and Source Code should be identical
between environments, specifics go into config table
• => similar to configuration files in other applications
Application Settings 53
On Upgrade Keep Values => respect the value upon
upgrade
54
Application Building
Email Templates
Email Templates 55
Manage Email
Templates
as part of
the application
Email Templates 56
Email Templates 57
Send email via API
begin
apex_mail.send (
p_to => '
[email protected]',
p_template_static_id => 'TEST1',
p_placeholders => '{'||
' "CUSTOMER_NAME":' || apex_json.stringify( 'Dietmar' )||
' ,"ITEMS_ORDERED":' || apex_json.stringify( 6 )||
' ,"MY_APPLICATION_LINK":' || apex_json.stringify( '' )||
' ,"ORDER_DATE":' || apex_json.stringify( '' )||
' ,"SHIPPING_ADDRESS_LINE_1":' || apex_json.stringify( '' )||
' ,"SHIPPING_ADDRESS_LINE_2":' || apex_json.stringify( '' )||
' ,"SHIP_TO":' || apex_json.stringify( '' )||
'}' );
end;
Email Templates 58
Email Templates 59
Just generate the HTML via the API
declare
l_subject varchar2( 4000 );
l_html clob;
l_text clob;
begin
apex_mail.prepare_template (
p_static_id => 'ORDER',
p_placeholders => '{ "ORDER_NUMBER": 5321, "ORDER_DATE": "01-Feb-2018",
"ORDER_TOTAL": "$12,000" }',
p_subject => l_subject,
p_html => l_html,
p_text => l_text );
end;
Email Templates 60
Manage Email Templates as part of
the application
Good separation of Templates and
data in placeholders
Easy to use
No complex logic supported
61
Items and Regions
62
Items and Regions
Text with Autocomplete
'Text with Autocomplete' item type using Oracle JET
63
Re-Implementation of the item type „Text with
Autocomplete“ based on Oracle JET
APEX 5.1 APEX 18.1
'Text with Autocomplete' item type using Oracle JET
64
Advantages:
• Improved accessibility
• Lazy loading with cache
• Minimum search characters
65
Items and Regions
Responsive Rich Text
Responsive Rich Text 66
Responsive Rich Text editor - automatically adjusts to the
region width.
Responsive Rich Text 67
Feature can be turned off in Shared Components >
Component Settings
Initially turned off for imported
/ upgraded applications
68
RESTful Services
(providing)
RESTful Services (providing) 69
SQL Workshop Integration upgraded to use ORDS APIs
New
Schemas Schemas Features
§ APEX_180100 § ORDS_METADATA only here
§ APEX_LISTENER § ORDS_PUBLIC_USER
§ APEX_REST_PUBLIC_USER
RESTful Services (providing) 70
“Old” RESTful services still available – READ ONLY
RESTful Services (providing) 71
“Old” RESTful services still available – READ ONLY
RESTful Services (providing) 72
New RESTful Services use API for ORDS_METADATA
RESTful Services (providing) 73
New RESTful Services use API for ORDS_METDATA
Features:
• More capable template handlers
• Autorest enablement for tables,
views and procedures
• OAUTH2 support
• Open API 2.0 (Swagger) Support
• ...
RESTful Services (providing) 74
Integration with Swagger to generate doc
• http://douggault.com/2018/03/19/swagger-doc-from-
apex-ords-restful-workshop
• SWAGGER UI 2.0+ Server (based on Node.js)
• https://swagger.io/download-swagger-ui/
RESTful Services (providing) 75
APEX Instance Administration
RESTful Services (providing) 76
77
SQL Workshop
78
SQL Workshop
Quick SQL
SQL Workshop > QuickSQL 79
QuickSQL is now integrated, used to be a packaged app
SQL Workshop > QuickSQL 80
81
SQL Workshop
Sample Datasets
SQL Workshop > Sample Datasets 82
Sample Datasets
SQL Workshop > Sample Datasets 83
Sample Datasets – very good to help with training and
troubleshooting
84
Packaged Applications
APEX_PKG_APP_INSTALL 85
Pre
18.1 Install, upgrade and delete packaged applications on the command
line:
declare
l_app_id number;
begin
-- Install
l_app_id := APEX_PKG_APP_INSTALL.install(
p_app_name => 'Sample Trees',
p_authentication_type => 'NATIVE_APEX_ACCOUNTS',
p_schema => 'DAUST_DE' );
end;
APEX_PKG_APP_INSTALL 86
Great for automatically installing all packaged applications after a
patch to look for gems or upgrade all applications at once.
Currently (not yet) officially supported but used by Oracle in the
cloud.
Data Dictionary View APEX_PKG_APPS
Install Packaged Applications 87
Allow „Modify Other Applications“ in security settings
88
PL/SQL APIs
PL/SQL APIs 89
APEX_ACL add_user_role
Application Access Control has_user_any_roles
has_user_role
remove_all_user_roles
remove_user_role
replace_user_roles
APEX_APP_SETTING get_value
Application settings set_value
PL/SQL APIs 90
APEX_APP_BUILDER_API delete_page_item
Generate Pages, Reports, etc. delete_region
Mainly used in Data Reporter,
not (yet) officially supported
APEX_APPLICATION_INSTALL get_no_proxy_domains
Application settings get_remote_server_base_url
get_remote_server_https_host
get_remote_server_ords_tz
set_remote_server
PL/SQL APIs 91
APEX_COLLECTION create_collection
Collection handling (Parameter p_truncate_if_exists)
APEX_CREDENTIAL clear_tokens
Public API for Secure Credentials set_persistent_credentials
(basic auth / oauth2) set_persistent_token
set_session_credentials
set_session_token
APEX_JWT decode
Handling von JSON Web Tokens encode
validate
PL/SQL APIs 92
https://blogs.oracle.com/apex/apex-181-early-adopter-2-rest-services-and-plsql
APEX_EXEC add_column
SQL Execution (mostly add_filter
remote), especially for plugin- add_order_by
developer add_parameter
close
execute_plsql
execute_remote_plsql
execute_web_source
get_anydata
get_clob
get_column
…
PL/SQL APIs 93
5.1.4
APEX_EXPORT get_application
Replacement for wwv_flow_utilities. get_workspace_files
export_application_to_clob get_feedback
get_workspace
APEX_MAIL prepare_template
Mail handling send_mail (support template)
APEX_SESSION attach
Session utils create_session
testing in sqlplus / sqlcl delete_session
running apex_exec in sqlplus / sqlcl detach
PL/SQL APIs 94
-- initialize session
apex_util.set_security_group_id(apex_util.find_security_group_id('TRAINING'));
apex_session.create_session ( p_app_id => 1386,
p_page_id => 4,
p_username => 'DIETMAR.AUST' );
-- get values from session state
select v('APP_ID') as app_id
, v('APP_SESSION') as app_session
, v('APP_USER') as app_user
, apex_app_setting.get_value( p_name => 'INSTANCE_TYPE' ) instance_type
from dual;
-- remove session
apex_session.delete_session ( p_session_id => nv( 'APP_SESSION' ) );
PL/SQL APIs 95
APEX_UTIL delete_feedback
Utilities delete_feedback_attachment
get_timeframe_lov_data
reply_to_feedback
set_parsing_schema_for_request
Multitenant applications
Switching datasets (different
schemas)
prepare_url (Parameter p_plain_url)
96
Data Dictionary
APEX_WORKSPACE_GROUPS 97
New columns application_id and application_name,
„true“ workspace groups now: where application_id is
null
APEX_WEBSERVICE_LOG 98
https://jastraub.blogspot.de/2018/03/apex-181-new-feature-
logging-web.html
Universal Theme light / dark navigation 99
Create Feature Page 100
Create Application Wizard supports Features (Blueprint)
Create Feature Page 101
Add „Blueprint“ features to your app AFTER creation
Questions? 102
Opal Consulting Email / Website
Zum Tilmeshof 11
[email protected] 50859 Köln www.opal-consulting.de
Germany
103
Backup
Resource Links 104
New Resource Links on APEX Workspace Homepage
• Shortcuts on Community Site
• Twitter, Youtube, LinkedIn, Facebook
Great idea … but everybody has different needs
Custom Resource Links 105
Customizing the Workspace or Instance Announcement
(HTML is only allowed here, not in the news items)
Custom Resource Links 106
Customizing the Workspace Announcement
Tree Region - Enhancements 107
• The Advanced: JavaScript Initialization Code attribute is
supported.
• JSDoc for Tree Region, easier to customize the tree
• Support Dynamic Action Event: Selection Change [Tree].
• Advanced Config option (nodeSelector) to support checkbox
selection.
• Tree region now supports the apex.region API => but AJAX
REFRESH is still not possible!
• Copy selection to clipboard.