Skip to main content

PL/SQL API

Overview

The plug-in package UC_FROALA_RTE exposes several functions and procedures allowing easier integration with Oracle APEX on the PL/SQL level:

  • Validate access token
  • Get the CLOB value
  • Set the CLOB value
  • Get the current CLOB checksum
  • Clear the CLOB value in the session state
  • Support for native clearing session state using browser URL

Functions

access_token_validate

The function validates the encoded access token string and returns true if a given string is a valid access token encoded string. Otherwise, the function returns false.

The function accepts arguments described in the table below.

ArgumentTypeDescription
p_access_tokenVARCHAR2The current value of the encoded access token.

Syntax

UC_FROALA_RTE.access_token_validate (   
p_access_token in varchar2
) return boolean;

Example

declare 
v_result boolean;
v_access_token_string varchar2(32767);
begin
v_result := UC_FROALA_RTE.(v_access_token_string)
end;

getChecksum

The function calculates and returns the current checksum for the given CLOB value.

The function accepts arguments described in the table below.

ArgumentTypeDescription
p_clobCLOBThe CLOB of which checksum will be returned.

Syntax

UC_FROALA_RTE.getChecksum(
p_clob IN CLOB
) return number;

Example

declare
v_clob clob;
v_checksum number;
begin
v_checksum := UC_FROALA_RTE.getChecksum(
p_clob => v_clob
);
end;

getValue

The function returns a page item current draft CLOB value stored in the plug-in session state. Learn more about draft CLOB the Item Plug-in \ Other integration with APEX \ Session state

The function accepts arguments described in the table below.

ArgumentTypeDescription
p_item_nameVARCHAR2An item name implementing the plug-in.

Syntax

UC_FROALA_RTE.getValue(   
p_item_name in VARCHAR2
) return CLOB;

Example

declare
v_clob clob;
begin
v_clob := UC_FROALA_RTE.getValue(
p_item_name => 'P1_PAGE_ITEM'
);
end;

Explanation

Initially, the function was created to fetch the CLOB value exceeding the VARCHAR2 limitation from the Oracle APEX session state. Until Oracle APEX 22.2 CLOB values bigger than 32 767 characters were raising a PL/SQL error when evaluating page item source attribute or when loading CLOB value using native form component.

Starting with Oracle APEX 22.2, we recommend relying on native Oracle APEX PL/SQL API to handle CLOB values in the APEX session state: APEX_UTIL.GET_SESSION_STATE.


clobGetHTML Signature 1

The function returns the given CLOB value with optional extra HTML code, ensuring that rich text formatting is the same as in the plug-in editor.

The function accepts arguments described in the table below.

ArgumentTypeDefaultDescription
p_clobCLOBA CLOB value to be displayed.
p_include_cssBooleanfalseWhen set to true, returned CLOB is computed to include the plug-in CSS files. Otherwise, the returned CLOB is the given

Syntax

UC_FROALA_RTE.clobGetHTML(
p_clob in CLOB,
p_include_css in BOOLEAN default false
) return CLOB;

Example 1

declare
v_clob clob;
begin
v_clob := UC_FROALA_RTE.getValue('P1_ITEM_NAME');

v_clob := UC_FROALA_RTE.clobGetHTML(v_clob);
end;

In the result of executing the example code, the variable v_clob is assigned with a new CLOB value including the given CLOB value embedded in additional div container. See the HTML code below for reference:

<div class="uc-froala--container uc-froala--readonly fr-view">
{CLOB}
</div>

Where {CLOB} is the plug-in session state CLOB value.

Example 2

declare
v_clob clob;
begin
v_clob := UC_FROALA_RTE.clobGetHTML(
p_clob => v_clob,
p_include_css => true
);
end;

In the result of executing the example code, the variable v_clob is assigned a new CLOB value, including

  • the plug-in CSS files preserving the editor's look and feel for rich text document
  • the given CLOB value embedded in additional div container. See the HTML code below for reference:
<link rel="stylesheet" href="{URL}uc.froala.css" type="text/css">
<link rel="stylesheet" href="{URL}css/froala_editor.pkgd.min.css" type="text/css">
<div class="uc-froala--container uc-froala--readonly fr-view">
{CLOB}
</div>

Where

  • {URL} is the current URL to the plug-in files
  • {CLOB} is the plug-in session state CLOB value.

clobGetHTML Signature 2

The function returns the value of the given page item with extra HTML code, ensuring that rich text formatting is the same as in the plug-in editor.

The function accepts arguments described in the table below.

ArgumentTypeDefaultDescription
p_item_nameVARCHAR2An item name implementing the plug-in.
p_include_cssBooleanfalseWhen set to true the result CLOB includes links to the plug-in CSS files.

Syntax

UC_FROALA_RTE.clobGetHTML(
p_item_name in VARCHAR2,
p_include_css in BOOLEAN default false
) return CLOB;

Example 1

declare
v_clob clob;
begin
v_clob := UC_FROALA_RTE.clobGetHTML('P1_ITEM_NAME');
end;

The example code assigns a new CLOB value with extra div container enclosing the page item P1_ITEM_NAME fetched from the plug-in session state.

See the HTML code below for reference:

<div class="uc-froala--container uc-froala--readonly fr-view">
{CLOB}
</div>

Where

  • {CLOB} is the plug-in session state CLOB value.

Example 2

declare
v_clob clob;
begin
v_clob := UC_FROALA_RTE.clobGetHTML(
p_item_name => 'P1_ITEM_NAME',
p_include_css => true
);
end;

In the result of executing the example code, the variable v_clob is assigned a new CLOB value, including:

  • the plug-in CSS files preserving the editor's look and feel for rich text document
  • the page item P1_ITEM_NAME value fetched from the plug-in session state embedded in an additional div container.

See the HTML code below for reference:

<link rel="stylesheet" href="{URL}uc.froala.css" type="text/css">
<link rel="stylesheet" href="{URL}css/froala_editor.pkgd.min.css" type="text/css">
<div class="uc-froala--container uc-froala--readonly fr-view">
{CLOB}
</div>

Where

  • {URL} is the current URL to the plug-in files
  • {CLOB} is the plug-in session state CLOB value

setValue Signature 1

The function sets the draft CLOB value in the plug-in session state and attempts to set a page item value in the APEX session state (using APEX_UTIL.SET_SESSION_STATE).

The function returns the checksum of the given CLOB and accepts arguments described in the table below.

ArgumentTypeDescription
p_item_nameVARCHAR2An item name implementing the plug-in.
p_valueCLOB

Syntax

UC_FROALA_RTE.setValue(   
p_item_name in varchar2,
p_value in CLOB
) return varchar2;

Example

declare
v_checksum number;
v_clob clob;
begin
v_checksum := UC_FROALA_RTE.setValue(
p_item_name => 'P1_PAGE_ITEM',
p_value => v_clob
);
end;

Explanation

Initially, the function was created to set the CLOB value exceeding the VARCHAR2 limitation in the plug-in session state. Until Oracle APEX 22.2 CLOB values bigger than 32 767 characters were reset to NULL in the APEX session state.

Starting with Oracle APEX 22.2, we recommend relying on native Oracle APEX PL/SQL API to handle CLOB values in the APEX session state: APEX_UTIL.SET_SESSION_STATE.

Learn more about the plug-in session state in the Item Plug-in \ Other integration with APEX \ Session state.


setValue Signature 2

The function sets the on-load or draft CLOB value in the plug-in session state based on the given CLOB value and page item. The function returns the checksum of the given CLOB.

The function accepts arguments described in the table below.

ArgumentTypeDescription
p_item_nameVARCHAR2An item name implementing the plug-in.
p_typeVARCHAR2The CLOB type to be set in the plug-in session state.
p_valueCLOBThe value of the CLOB to be set in the plug-in session state.
p_set_session_stateBooleanWhen true, the page item session state is set to the given CLOB value using native Oracle APEX PL/SQL API.

p_type

The argument valid values are the following:

  • UC_FROALA_RTE.c_clob_type_draft
  • UC_FROALA_RTE.c_clob_type_onload.

Syntax

UC_FROALA_RTE.setValue( 
p_item_name in varchar2,
p_type in varchar2,
p_value in CLOB,
p_set_session in boolean default true
) return varchar2;

Example

declare
v_clob clob;
v_checksum number;
begin
v_checksum := UC_FROALA_RTE.setValue(
p_item_name => 'P1_PAGE_ITEM',
p_type => UC_FROALA_RTE.c_clob_type_draft,
p_value => v_clob,
p_set_session => true
);
end;

Explanation

Initially, the function was created to set the CLOB value exceeding the VARCHAR2 limitation in the plug-in session state. Until Oracle APEX 22.2 CLOB values bigger than 32 767 characters were reset to NULL in the APEX session state.

Starting with Oracle APEX 22.2, we recommend relying on native Oracle APEX PL/SQL API to handle CLOB values in the APEX session state: APEX_UTIL.SET_SESSION_STATE.

Learn more about the plug-in session state in the Item Plug-in \ Other integration with APEX \ Session state.


Procedures

clobDisplay Signature 1

The procedure displays the given CLOB value with extra HTML code, ensuring that rich text formatting is the same as in the plug-in editor.

The function accepts arguments described in the table below.

ArgumentTypeDefaultDescription
p_clobVARCHAR2NULLAn item name implementing the plug-in.
p_include_cssBooleantrueWhen set to true, CLOB is displayed including plug-in CSS files and outer div container

Syntax

UC_FROALA_RTE.clobDisplay(
p_clob in clob,
p_include_css in boolean defeault true
);

Example 1

declare
v_clob clob;
begin
v_clob clob := UC_FROALA_RTE.getValue('P1_ITEM_NAME');

UC_FROALA_RTE.clobDisplay(
p_clob => v_clob
);
end;

The example code prints to the browser the following HTML:

<div class="uc-froala--container uc-froala--readonly fr-view">
{CLOB}
</div>

where {CLOB} is the given CLOB value.

The plug-in CSS files are added to the bottom of the page using the Oracle APEX API APEX_CSS.ADD_FILE. See the code below to see what files are added.

<link rel="stylesheet" href="{URL}uc.froala.css" type="text/css">
<link rel="stylesheet" href="{URL}css/froala_editor.pkgd.min.css" type="text/css">

The {URL} is the current URL to the plug-in files generated by the plug-in.

Example 2

declare
v_clob clob;
begin
v_clob clob := UC_FROALA_RTE.getValue('P1_ITEM_NAME');

UC_FROALA_RTE.clobDisplay(
p_clob => v_clob,
p_include_css => false
);
end;

The example code prints to the browser only the CLOB HTML without additional CSS files and outer container:

{CLOB}

Where {CLOB} is the given CLOB value without any modifications.


clobDisplay Signature 2

The procedure displays a CLOB value of the given item with extra HTML code, ensuring that rich text formatting is the same as in the plug-in editor.

The procedure accepts arguments described in the table below.

ArgumentTypeDescription
p_item_nameVARCHAR2An item name implementing the plug-in.

Syntax

UC_FROALA_RTE.clobDisplay(
p_item_name in varchar2
p_include_css in boolean defeault true
);

Example 1

begin
UC_FROALA_RTE.clobDisplay(
p_item_name => 'P1_ITEM_NAME'
);
end;

The example code prints to the browser the following HTML:

<div class="uc-froala--container uc-froala--readonly fr-view">
{CLOB}
</div>

where {CLOB} is the given page item value in fetched from the plug-in session state.

The plug-in CSS files are added to the bottom of the page using the Oracle APEX API APEX_CSS.ADD_FILE.

<link rel="stylesheet" href="{URL}uc.froala.css" type="text/css">
<link rel="stylesheet" href="{URL}css/froala_editor.pkgd.min.css" type="text/css">

The {URL} is the current URL to the plug-in files generated by the plug-in.

Example 2

begin
UC_FROALA_RTE.clobDisplay(
p_item_name => 'P1_ITEM_NAME'
p_include_css => false
);
end;

The example code prints to the browser a page item CLOB value without additional CSS files and outer container:

{CLOB}

Where {CLOB} is rich text editor HTML without any modifications.


clear

The procedure flushes the plug-in session state for the given page item implementing the plug-in.

The procedure accepts arguments described in the table below.

ArgumentTypeDescription
p_item_nameVARCHAR2An item name implementing the plug-in.

Syntax

UC_FROALA_RTE.clear(
p_item_name in varchar2
);

Example

begin
UC_FROALA_RTE.clear(
p_item_name => 'P1_UC_RTE_PRO'
);
end;

Explanation

Learn more about the plug-in session state in the Item Plug-in \ Other integration with APEX \ Session state


manageClearCache

Learn more about the plug-in session state in the Item Plug-in \ Other integration with APEX \ Session state

The procedure clears the plug-in session state based on the current URL.

The procedure has to be implemented as an application process (Shared Components \ Application Processes) with the execution point set to On Load: Before Header (page template header).

The procedure doesn't accept any arguments.

Syntax

UC_FROALA_RTE.manageClearCache;

Example

begin
UC_FROALA_RTE.manageClearCache;
end;

setValue

Learn more about the plug-in session state in the Item Plug-in \ Other integration with APEX \ Session state

The procedure sets the plug-in on-load or draft CLOB value in the plug-in collection based on the given CLOB value. The procedure updates the given page item session state to the given CLOB value, respecting Oracle APEX limitations for CLOB support in the session state.

The procedure accepts arguments presented in the table below.

ArgumentTypeDescription
p_item_nameVARCHAR2An item name implementing the plug-in.
p_valueCLOBA CLOB value for a rich text document.

Syntax

UC_FROALA_RTE.setValue(   
p_item_name in varchar2,
p_value in CLOB
);

Example

declare
v_clob clob;
begin
UC_FROALA_RTE.setValue(
p_item_name => 'P1_UC_RTE_PRO',
p_value => v_clob
);
end;