Skip to main content

Plug-in Session State

The plug-in implements it's own session state using APEX collections and monitors/relies on APEX page item session state. It allows the plug-in handling CLOB values across APEX versions. This documents covers the plug-in session state implemented using Oracle APEX collections.

Oracle APEX limitations unleashed

Before Oracle APEX 22.2 page item value is stored in APEX session state using VARCHAR2, which implicts page item maximum value of 32 767 characters. Setting a page item value exceeding the limitation results in assigning NULL value. On the other hand loading values exceeding the VARCHAR2 limitation into page item session state results in raising PL/SQL errror: ORA-06502: PL/SQL: numeric or value error.

Rich Text Editor Pro enables handling CLOB values for Oracle APEX 19.2 using the supporting process plug-in and the plug-in PL/SQL API. When the plug-in is implemented in Oracle APEX 22.2 onwards, the plug-in relays on the native session state and no additional adjustments are required.

Plug-in session state

Rich Text Editor Pro uses Oracle APEX collection UC_FROALA to handle session state of currently edited rich text document. The collection is used by all plug-in instances across application pages and it stores the following information about rich text documents:

  • rich text document HTML as CLOB value
  • images added or removed from a rich text document (including image meta data)
  • classes applied using application builder page designer
  • APEX processes meta-data used to load CLOB value
  • Initialization PL/SQL variables

The plug-in collection uses columns c001 and c002 to identify which plug-in instance meta-data is stored in the collection row.

ColumnTypeDescription
C001VARCHAR2Page item name for which collection row is created.
C002VARCHAR2Describes what information is stored in the collection row.

The column c002 can have values described in the table below.

ValueDescription
ONLOADThe collection row contains information about on-load CLOB value loaded when the plug-in was rendered by Oracle APEX.
DRAFTThe collection row contains information about draft CLOB value currently stored in the plug-in session state.
IMAGEThe collection row describe an image added or removed to/from rich text document..
CLASSThe collection row describes classes added to a page item using page designer Advanced \ CSS Classes attribute
LOADThe collection row describes a page process implementing the supporting process plug-in to load CLOB value.
VARThe collection row describes the plug-in PL/SQL variables values assigned when the plug-in was rendered.
Collections row types

Learn more about each collection row column usage in the section The plug-in collection.

Get document CLOB value

The currently edited document can be fetched from the plug-in session state using the plug-in PL/SQL function getValue.

Set document CLOB value

The current document in the plug-in session state can be set using the plug-in PL/SQL procedure setValue

The plug-in collection

On-load CLOB

The on-load CLOB is used by the plug-in validation procedure checking (executed on page submission) if currently edited rich text document wasn't altered in the database by other user since it was loaded to the rich text editor.

This rich text document CLOB value is created in the plug-in session state when:

  • the supporting process plug-in is used to load CLOB value from the database on page load.
  • the plug-in PL/SQL API is used to load CLOB value from the database on page load
  • a page item implementing the plug-in is rendered by Oracle APEX (plug-in checks whether supporting process plug-in or PL/SQL API was used to load a value)

The plug-in session state for on-load CLOB is described by the plug-in collection row described in the table below.

ColumnTypeValue description
C001VARCHAR2A page item name implementing the plug-in.
C002VARCHAR2Always set to ONLOAD.
N001NUMBERThe checksum of CLOB value calculated by the plug-in.
N002NUMBERThe length of CLOB value in bytes.
CLOB001CLOBThe rich text document HTML
Checksum validation

Draft CLOB

The draft CLOB is used by the plug-in to reflect the current value of rich text document in the plug-in session state. This value is used to update CLOB value in the database on page submission when using the supporting process plug-in or the plug-in PL/SQL API.

The CLOB value is stored in the plug-in session state when:

  • the supporting process plug-in is used to load CLOB value from the database on page load.
  • the plug-in PL/SQL API is used to load CLOB value from the database on page load
  • a page item implementing the plug-in is rendered by Oracle APEX (plug-in checks whether supporting process plug-in or PL/SQL API was used to load a value)
  • the supporting dynamic action Update CLOB is executed
  • a page implementing the plug-in is submitted

The plug-in session state for draft CLOB is described by the plug-in collection row described in the table below.

ColumnTypeDescription
C001VARCHAR2An item name implementing the plug-in
C002VARCHAR2Always set to DRAFT
N001NUMBERThe checksum of CLOB value calculated by the plug-in.
N002NUMBERThe length of CLOB value in bytes.
CLOB001CLOBThe rich text document HTML

Images

Whenever images in rich text document are added, updated or removed, the plug-in updates it's session state storing the most recent information about images. The plug-in tracks all image changes, allowing maintaining images in the database.

Live demo

The plug-in sample application includes live example of images in the plug-in session state. Click here to open to the plug-in live demo for images in the plug-in session state.

The table below presents an image meta-data stored in the plug-in session state:

ColumnTypeDescription
C001VARCHAR2An item name implementing the plug-in
C002VARCHAR2Must equal IMAGE
C003VARCHAR2An unique image ID assigned by the plug-in, for example, ui-id-1
C004VARCHAR2Flag Y or N indicating whether an image was embedded in rich text document when the plug-in was initialized
C005VARCHAR2Flag Y or N indicating whether an image was added to rich text document after the plug-in was initialized
C006VARCHAR2Flag Y or N indicating whether an image was removed from rich text HTML after the plug-in was initialized
C007VARCHAR2Flag Y or N indicating whether an image is a base64 image
C008VARCHAR2Flag Y or N indicating whether an image is uploaded using the plug-in RESTful service
C009VARCHAR2Flag Y or N indicating whether an image can be safely removed from the database on page submission. An uploaded image can be safely removed from the database when an image URL is not shared with other images
C010VARCHAR2An image current URL. An image URL is available only for non-base64 images (uploaded using RESTful service or added manually via URL)
C011VARCHAR2An image's current ID stored in the database - available only for images uplaoded using the plug-in

Classes

The table below presents the collection columns describing class names added to the plug-in item using an attribute Item \ Appearance \ CSS Classes.

ColumnTypeDescription
C001VARCHAR2An item name implementing the plug-in.
C002VARCHAR2Must eual CLASS.
C010VARCHAR2The provided classes in the page designer.

Processes

The table below presents the collection columns describing processes used to load CLOB value into the plug-in collection.

ColumnTypeDescription
C001VARCHAR2An item name implementing the plug-in.
C002VARCHAR2Must eual LOAD.
C003VARCHAR2Page request used to load a page.
C003VARCHAR2An internal APEX process ID.

PL/SQL Variables

The table below presents the collection columns describing initialization PL/SQL variables used by the plug-in.

ColumnTypeDescription
C001VARCHAR2An item name implementing the plug-in.
C002VARCHAR2Must eual VAR.
C003VARCHAR2Variable name
C004VARCHAR2Variable type
C005VARCHAR2Variable value
Plug-in PL/SQL initialization variables

Toolbar PL/SQL definition

The table below presents the collection columns describing toolbar definition set using the plug-in PL/SQL API toolbar_init_group.

ColumnTypeDescription
C001VARCHAR2An item name implementing the plug-in.
C002VARCHAR2Must eual TOOLBAR.
C003VARCHAR2The toolbar responsive threshold [1]
C004VARCHAR2The toolbar group [2]
C005VARCHAR2The number of visible buttons in given group
C006VARCHAR2The group alignment in the toolbar
C007VARCHAR2The group button ids separated with comma
annotations

Other topics

Difference between on-load CLOB and draft CLOB

The on-load CLOB and draft CLOB are created simultaneously when the plug-in is rendered on page load (or when the supporting process plug-in is used to load CLOB from the database). Both have the same value, length, and checksum. The on-load CLOB value is preserved until the next page load so it can be used to perform CLOB checksum validation on page submission. On the other hand, the draft CLOB is updated whenever

  • a supporting dynamic action Update CLOB is triggered
  • a page implementing the plug-in is submitted
  • the plug-in PL/SQL API setting plug-in session state is executed
Checksum validation

Known Issues

Item source

Despite the introduction of CLOB support in Oracle APEX 22.2, using the page item source attribute to load a CLOB value can cause PL/SQL issues. Page item source types such as PL/SQL Expression and PL/SQL Function Body should theoretically support CLOB values exceeding the VARCHAR2 limitation (32,767 characters) but in reality, they raise an error at the APEX engine level, which is beyond the plug-in's control.