59.98 PREPARE_URL Function
Note:
Oracle recommends using APEX_PAGE.GET_URL
instead of PREPARE_URL
for improved readability.
See GET_URL Function.
The PREPARE_URL function serves two purposes:
-
To return an APEX navigation URL with the Session State Protection checksum argument (&cs=) if one is required. For security, the URL will not contain a checksum if the specified application is located in a different workspace.
-
To return an APEX navigation URL with the session ID component replaced with zero (0) if the zero session ID feature is in use and other criteria are met.
Note:
The PREPARE_URL
function returns the APEX navigation URL with &cs=<large hex value>
appended. If you use this returned value (such as in JavaScript), you may need to escape the ampersand in the URL to conform with syntax rules of the particular context.
Syntax
APEX_UTIL.PREPARE_URL (
p_url IN VARCHAR2,
p_url_charset IN VARCHAR2 DEFAULT NULL,
p_checksum_type IN VARCHAR2 DEFAULT NULL,
p_triggering_element IN VARCHAR2 DEFAULT 'this',
p_plain_url IN BOOLEAN DEFAULT FALSE,
RETURN VARCHAR2;
Parameters
Parameter | Description |
---|---|
p_url |
An APEX navigation URL with all substitutions resolved. |
p_url_charset |
The character set name (for example, UTF-8 ) to use when escaping special characters contained within argument values.
|
p_checksum_type |
Null or any of the following values:
|
p_triggering_element |
A jQuery selector (for example, #my_button , where my_button is the static ID for a button element), to identify which element to use to trigger the dialog. This is required for Modal Dialog support.
|
p_plain_url |
If the page you are calling APEX_UTIL.PREPARE_URL from is a modal dialog, specify p_plain_url to omit the unnecessary dialog code in the generated link. By default, if this function is called from a modal dialog, extra code to close the modal dialog is included in the generated URL.
|
Example 1
The following example shows how to use the PREPARE_URL
function to return a URL with a valid 'SESSION' level checksum argument. This URL sets the value of P1_ITEM
page item to xyz
.
DECLARE
l_url varchar2(2000);
l_app number := v('APP_ID');
l_session number := v('APP_SESSION');
BEGIN
l_url := APEX_UTIL.PREPARE_URL(
p_url => 'f?p=' || l_app || ':1:'||l_session||'::NO::P1_ITEM:xyz',
p_checksum_type => 'SESSION');
END;
Example 2
The following example shows how to use the PREPARE_URL
function to return a URL with a zero session ID. In a PL/SQL Dynamic Content region that generates f?p
URLs (anchors), call PREPARE_URL
to ensure that the session ID is set to zero when the zero session ID feature is in use, when the user is a public user (not authenticated), and when the target page is a public page in the current application:
htp.p(APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || :APP_ID || ':10:'|| :APP_SESSION
||'::NO::P10_ITEM:ABC'));
When using PREPARE_URL
for this purpose, the p_url_charset
and p_checksum_type
arguments can be omitted. However, it is permissible to use them when both the Session State Protection and Zero Session ID features are applicable.
See Also:
About Enabling Support for Bookmarks in Oracle APEX App Builder User’s Guide
Parent topic: APEX_UTIL