Oracle APEX Mini-Levels: From Checkboxes to Collections (and What I Learned Along the Way)

Intro

Have you ever needed to store user selections in Oracle APEX without creating new tables?
In a recent experiment, I built a mini โ€œgameโ€ of levels inside APEX to explore this โ€” and each step revealed an important concept thatโ€™s useful in real-world apps.

This post is a walkthrough of Levels 1โ€“3 of that journey: Dynamic Actions, Select-All checkboxes, and Collections โ€” with the key lessons that go beyond just the demo.


Level 1 โ€” Counter Whisperer ๐Ÿงฎ

What I built: A simple Select List (1..10) that updates a Display Only item to show: โ€œYou picked N.โ€
Why it matters: A gentle introduction to Dynamic Actions (DA).

Lessons

  • Dynamic Actions: How to set item values based on other items without writing PL/SQL.

  • apex.message: Adding a page success toast (apex.message.showPageSuccess) is an easy UX win.


Level 2 โ€” Checkbox Forge ๐Ÿ”ฒ

What I built: When the user picks a number, the page renders that many rows, each with a checkbox. Plus a header checkbox for โ€œSelect All.โ€

Lessons

  • Generate rows with SQL:

      select level as seq
      from dual
      connect by level <= :P1_COUNT
    
  • apex_item.checkbox2 to render checkboxes tied to apex_application.g_f01.

  • Select All logic: Why Dynamic Scope + Container in DA is necessary.

    • If the region refreshes, Static bindings break.

    • Correct pattern:

      • When selector: input[name=f01]

      • Static Container: #CHOICES

  • Mental model:

    • Master โ†’ children: set all to master.checked.

    • Children โ†’ master: if all rows checked โ†’ master checked; else unchecked.


Level 3 โ€” Collection Vault ๐Ÿ—„๏ธ

What I built: User ticks some rows โ†’ clicks Save โ†’ values stored in an APEX Collection (C_CHECKS) โ†’ displayed back in a report.

Code (simplified)

if apex_collection.collection_exists('C_CHECKS') then
    apex_collection.delete_collection('C_CHECKS');
end if;
apex_collection.create_collection('C_CHECKS');

for i in 1 .. apex_application.g_f01.count loop
    apex_collection.add_member(
        p_collection_name => 'C_CHECKS',
        p_c001            => apex_application.g_f01(i)
    );
end loop;

Final result

User selects the count from the select list to create those much checkbox items, then user picks checkboxes, clicks Save, and the selections are stored in a Collection and displayed below in another report and when user clicks on Clear button the collection is deleted and the values are gone.

Lessons

  • Collections are perfect for temporary, session-scoped storage (shopping carts, filters, wizard steps).

  • Session State Protection (SSP): Donโ€™t submit client-modified values for Display Only items.

    • Fix: Keep Send on Page Submit = No, and recompute server-side or via DA.

Key Takeaways ๐Ÿ’ก

  • Dynamic vs Static event scope in APEX DA = understanding event delegation.

  • Collections let you model temporary data structures without schema changes.

  • SSP is your guardrail against tampering โ€” respect it.

  • Even small demos surface big real-world lessons.


Closing

This was just Levels 1โ€“3 of my mini-APEX game. Next up: Interactive Grids with bulk actions โ€” and thatโ€™s where AJAX callbacks will enter the picture.

๐Ÿ‘‰ Have you used APEX Collections in your apps? For what use cases?
Drop a comment โ€” Iโ€™d love to hear.

#OracleAPEX #LowCode #PLSQL #WebDev #SQL

5
Subscribe to my newsletter

Read articles from Bhuvnesh Singh Chauhan (bhuvi_champ) directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Bhuvnesh Singh Chauhan (bhuvi_champ)
Bhuvnesh Singh Chauhan (bhuvi_champ)