Search This Blog

Tuesday, July 1, 2025

Implement the "APEX Util" Button

The APEX Util button retrieves and displays the session state values stored using apex_util.get_session_state().

Implementation Steps

  1. Set the Button Action to Defined by Dynamic Action.

  2. Create a Dynamic Action with the following attributes: 

    • Event: Click

    • Action: Execute PL/SQL Code

    • PL/SQL Code:

DECLARE

    v_fname VARCHAR2(100);

    v_lname VARCHAR2(100);

BEGIN

    v_fname := apex_util.get_session_state('P1_FNAME');

    v_lname := apex_util.get_session_state('P1_LNAME');

    apex_debug.info('Stored First Name: ' || v_fname);

    apex_debug.info('Stored Last Name: ' || v_lname);

END;

This logs the stored values in the APEX debug console for troubleshooting and validation.


This tutorial demonstrated different ways to interact with text fields and buttons in Oracle APEX. The buttons use various techniques, including session state management, page submission, dynamic SQL execution, JavaScript manipulation, and APEX utilities.

Each method serves a specific purpose:

  • Clear Session: Clears values from session state.

  • Submit: Submits the page.

  • APEX Submit: Stores values in session state before submission.

  • Dynamic SQL: Executes SQL dynamically.

  • Dynamic JS: Modifies text fields with JavaScript.

  • APEX Util: Retrieves stored session values for debugging.

By combining these methods, you can create highly interactive and dynamic APEX applications.


EXAMPLE:

In this application we have two text fields and 6 buttons:

  • Text fields

    • FName

    • LName

  • Buttons

    • Clear Session

    • Submit

    • Apex Submit

    • Dynamic SQl

    • Dynamic JS

    • Apex Util

ClearSessions Button

  • Create button named “Clear Session”

A screenshot of a computer

Description automatically generated

  • Create a Dynamic Action

  • On the true Branch

A black and grey striped background

Description automatically generated


A black rectangular object with white text

Description automatically generated


A computer screen shot of a black bar

Description automatically generated



  • Create a second True Branch

A black screen with white text

Description automatically generated


A screenshot of a computer program

Description automatically generated

Via Submit Button

A screenshot of a computer

AI-generated content may be incorrect.


Via APEX Submit

A black rectangular object with a black stripe

Description automatically generated


A screenshot of a computer

Description automatically generated

Via Dynamic SQL

  • Create a Dynamic Action

A screenshot of a computer

Description automatically generated

  • In the true branch

A black screen with white text

Description automatically generated


A screenshot of a computer

Description automatically generated


  • In the Processing tab

A screenshot of a computer

AI-generated content may be incorrect.

  • With the following values

A black and grey striped background

Description automatically generated


A screenshot of a computer

Description automatically generated


A black and white text

Description automatically generated


A black and grey striped background

Description automatically generated


Via Dynamic JavaScript

  • At the page level

A screenshot of a computer

Description automatically generated


A screenshot of a computer

Description automatically generated


A screenshot of a computer

Description automatically generated


  • Create a dynamic action

A screenshot of a computer

Description automatically generated


  • In the True branch

A black rectangular object with white text

Description automatically generated


A black and grey background

Description automatically generated with medium confidence


A black and white text

Description automatically generated with medium confidence



Via App Util

Viewing the session values

At the bottom of your page select Session > View Session variables



A screenshot of a computer

Description automatically generated


In this example the session variables are EMPTY, but had we had any data, it would display under Item Values.

A screenshot of a computer

AI-generated content may be incorrect.

After the session is cleared

A screenshot of a computer

Description automatically generated






No comments:

Post a Comment

Learning ORACLE APEX: Creating a Complete Application from a CSV File

  Learning ORACLE APEX: Creating a Complete Application from a CSV File Start with a simple CSV dataset and finish with a working, shareable...