Search This Blog

Friday, July 18, 2025

CREATING A SHUTTLE ITEM ON THE FORM PAGE IN PAGE DESIGNER

Introduction

A Shuttle item in Oracle APEX is a form element that allows users to move one or more values from an available list to a selected list. It’s particularly useful when you want to let users assign multiple options to a record — such as assigning users to roles, students to classes, or employees to projects. This blog will walk you through the steps to create a Shuttle item on a form page using Page Designer, explain how it works behind the scenes, and offer detailed examples and best practices.

How to Create a Shuttle Item – Step-by-Step

Use Case Example:
We have a projects table and a project_employees association table. We want to create a form where users can assign multiple employees to a project using a shuttle.

1. Open Your Page in Page Designer

  • Log in to your APEX workspace.

  • Open your application and go to the form page where you want to add the Shuttle item.

2. Create the Shuttle Item

  • In Page Designer, under the appropriate region, click + to add a new item.

  • Select Shuttle as the item type.

  • Set a name such as P1_EMPLOYEE_LIST.

3. Define the List of Values (LOV)

Under the Shuttle item’s List of Values section:

  • Set Type to SQL Query.

  • Example query:

    SELECT full_name d, employee_id r
    FROM employees
    ORDER BY full_name
    
    • d is the display value shown to the user.

    • r is the return value stored when submitted.

4. Configure Storage

The Shuttle will return a colon-separated list of values (e.g., 101:104:109).
You have two main storage options:

  • A. Store as a delimited string in one column (not recommended for relational data).

  • B. Process the values in a BEFORE SUBMIT PL/SQL process and insert them into a child table (recommended).

5. Process the Shuttle Selection

Create a PL/SQL page process to handle the selected values.

Example:

DECLARE
   l_array apex_application_global.vc_arr2;
BEGIN
   -- Delete existing assignments for the project
   DELETE FROM project_employees WHERE project_id = :P1_PROJECT_ID;

   -- Convert shuttle string to an array
   l_array := apex_util.string_to_table(:P1_EMPLOYEE_LIST);

   -- Insert selected employees
   FOR i IN 1..l_array.count LOOP
      INSERT INTO project_employees (project_id, employee_id)
      VALUES (:P1_PROJECT_ID, l_array(i));
   END LOOP;
END;

Make sure the Shuttle item is included in "Items to Submit".

Extensive Example – Assign Courses to a Student

  1. Shuttle Item: P2_COURSE_LIST

  2. SQL Query:

    SELECT course_name, course_id FROM courses ORDER BY course_name
    
  3. On Submit Process:

    DECLARE
      l_course_ids apex_application_global.vc_arr2;
    BEGIN
      DELETE FROM student_courses WHERE student_id = :P2_STUDENT_ID;
    
      l_course_ids := apex_util.string_to_table(:P2_COURSE_LIST);
    
      FOR i IN 1..l_course_ids.count LOOP
         INSERT INTO student_courses (student_id, course_id)
         VALUES (:P2_STUDENT_ID, l_course_ids(i));
      END LOOP;
    END;


This section demonstrates how to create shuttle item type. In this example, you first create a report and form on the DEPT table that shows which employees are assigned to a given department. Then, you create a shuttle item that lists employees alphabetically to make it easier to assign employees to a department.

To create a shuttle item on a form:

  1. View the page in Page Designer:

    1. On the Workspace home page, click the App Builder icon.

    2. Select an application.

    3. Select a page.

Page Designer appears.

  1. In Page Rendering, right-click region containing the form and select Create Page Item.

  2. In the Property Editor, edit the following attributes:

    1. Identification: Name - Enter the name of this item (for example, PX_EMP_LIST).

Where PX in the item name (for example P2_EMP_LIST) indicates the page on which the item resides.

  1. Identification: Type - Select Shuttle.

  1. In the Property Editor, edit the List of Values attributes:

    1. List of Values: Type - Select SQL Query.

    2. List of Values: SQL Query, enter:

 

SELECT ename, empno FROM emp ORDER BY 1

  1. In the Property Editor, edit the Source attributes

    1. Source: Type - Select SQL Query (return colon separated value).

    2. Source: Item Source Value - Enter the SQL Query that returns one or more rows to be used as the source for this item value. If the result contains multiple rows then the value from each row is formed into a single colon delimited value. For example:

 

SELECT empno FROM emp WHERE deptno = :P8_DEPTNO ORDER BY enam


Configuring Page Item Security

To configure page item security:

  1. View the page in Page Designer:

    1. On the Workspace home page, click the App Builder icon.

    2. Select an application.

    3. Select a page.

Page Designer appears.

  1. In either the Rendering tab or the Layout tab, select the item to edit.

The Property Editor displays the item attributes.

Tip:

Attributes are organized in groups. To find a group or attribute, enter keywords in the Filter Properties field, or click Go to Group and select the group.

  1. Find Security. Configure the following Security attributes.

Table 13-2 Property Editor - Page Item, Security

Attribute

Description

Authorization Scheme

Select an authorization scheme which must evaluate to TRUE in order for this component to be rendered or otherwise processed.

See Also: Providing Security Through Authorization

Session State Protection

Select a Session State Protection level. Options include:

  1. Unrestricted - The item can be set by passing the item in a URL or in a form. No checksum is required in the URL.

  2. Checksum Required - Application Level - The item can be set by passing the item in a URL that includes a checksum specific to the workspace and application.

  3. Checksum Required - User Level - The item can be set by passing the item in a URL that includes a checksum specific to the workspace, application and user.

  4. Checksum Required - Session Level - The item can be set by passing the item in a URL that includes a checksum specific to the session.

  5. Restricted - May not be set from browser - The item cannot be altered using the URL or POSTDATA. Select this option to restrict what can set the item value to internal processes, computations, and so on. This attribute only applies to items that are not used as data entry items and is always observed, even if Session State Protection is disabled. Use this attribute for page or application items that have the following Display As types

    • Display Only (Save State=No)

    • Text Field (Disabled, does not save state)

See AlsoPreventing URL Tampering

Store value encrypted in session state

Specify whether to encrypt this item when stored in session state. If the contents of an item contain sensitive data, then you should encrypt the value when it is stored in the Oracle APEX session state management tables. Otherwise, anyone with rights to read the APEX metadata tables could potentially write a query to extract this sensitive data.

Values up to 4000 bytes in length can be encrypted. Attempts to encrypt values longer than 4000 bytes produce an error message.

Escape Special Characters

This attribute only displays with some item types. Select On to prevent Cross-Site Scripting (XSS) attacks. Select Off if you want that HTML tags which are stored in the page item or in the entries of a list of value are actually rendered.

See AlsoUnderstanding Cross-Site Scripting Protection

Restricted Characters

Select how to restrict the characters that can be saved in session state. APEX displays an error message if a user tries to save data that does not conform to the selected character restriction. Restricting the characters hardens application security and is a possible counter measure to cross-site scripting (XSS) attacks.

Available options include:

  1. All characters can be saved - No restriction applies.

  2. Whitelist for a-Z, 0-9 and space - Only allow characters a-z, A-Z, 0-9, and space.

  3. Blacklist HTML command characters (<>") - Reserved HTML characters cannot be saved.

  4. Blacklist &<>"/;,*|=% and --: - The following characters cannot be saved:

&, <, >, ", /, ;, ",", *, |, =, % and "--" (PL/SQL comment)

  1. Blacklist &<>"/;,*|=% or -- and new line - The following characters cannot be saved:

&, <, >, ", /, ;, ",", *, |, =, %, "--", and new line characters

See AlsoUnderstanding Cross-Site Scripting Protection


Best Practices

  • Always delete and re-insert values when using many-to-many tables to simplify logic.

  • Use foreign keys and indexes on association tables for better performance.

  • If the list is large, consider using AJAX-based LOVs for better load time.

  • Handle NULL submissions gracefully to avoid losing all assignments unintentionally.

  • Use descriptive labels and instructions to help users understand how the shuttle works.

  • Consider adding a search box or filtering logic in the LOV SQL if the list grows large.

Oracle APEX Documentation
Oracle APEX Shuttle Item Reference

Conclusion
The Shuttle item in Oracle APEX is a powerful and user-friendly control for managing multi-select relationships on forms. Whether you are assigning roles, tagging records, or linking entities, shuttle items provide a clean UI that simplifies the selection process. When combined with PL/SQL processes and well-structured tables, they can handle complex relationships with ease and precision. Mastering the Shuttle control is a great step toward building more interactive and functional APEX applications.

No comments:

Post a Comment

How Do I Make a Faceted Search Map Page in Oracle APEX

Combining faceted search with a map region in Oracle APEX enables users to filter data visually and spatially at the same time. This design ...