Search This Blog

Monday, June 23, 2025

How Do I Use the Button for Navigation - Using parameters

 

Introduction

In Oracle APEX, buttons can do more than just trigger actions—they can also pass parameters to other pages or applications, enabling more dynamic and context-aware navigation. This is especially useful when you need to carry values like user IDs, form data, or filter criteria from one page to another. In this guide, we'll walk through how to configure a button to navigate to a different page while passing parameters, all using APEX’s intuitive declarative tools. Whether you're building multi-step workflows or simply linking related content, mastering parameterized navigation will make your applications more powerful and interactive.


In Oracle APEX, **Button Navigation Using Parameters** allows you to pass values from one page to another, making your applications dynamic and context-aware. Below is a **detailed step-by-step explanation** on how to implement this feature using Oracle APEX's built-in tools.


GOAL:

Create a button on Page A that, when clicked, navigates to Page B and passes parameters (e.g., item values like `:P1_EMP_ID`) to that target page (e.g., `P2_EMP_ID`).


STEP-BY-STEP GUIDE

Step 1: Add Items to Hold the Data

* On **Page A (source page)**, ensure you have items (e.g., `P1_EMP_ID`) that contain the values you want to pass.

* On **Page B (target page)**, create matching items (e.g., `P2_EMP_ID`) to receive these values.


Step 2: Create a Button on Page A

1. **Go to Page Designer** on **Page A**.

2. In the **Layout** pane, select the region where the button should go.

3. Right-click → **Create Button**.

4. Name it, e.g., `GO_TO_EMP_DETAILS`.

5. Set **Action** to `Redirect to Page in this Application`.




Step 3: Set the Target Page and Pass Parameters

1. In the **Button Attributes**, scroll down to **Behavior**.

2. Under **Target**, set:

   * **Action**: `Redirect to Page in this Application`

   * **Page**: enter `2` (or the actual target page number)

3. Click the **Set Items** link (or use the "Parameters" icon).




Step 4: Define the Parameter Mapping

In the **Set Items** dialog:

* Add a new row for each parameter.
* Example:

  •   Name**: `P2_EMP_ID` (Item on Page B)
  •   Value**: `&P1_EMP_ID.` or select `P1_EMP_ID` from the dropdown

This means: "Set `P2_EMP_ID` on Page 2 to the value of `P1_EMP_ID` from Page 1".

Click **OK** to save.




Step 5: Use the Parameter on the Target Page (Page B)


On **Page B**:

* Use `:P2_EMP_ID` in any SQL queries, dynamic actions, or PL/SQL logic.

* Example in a report's SQL:

  SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID = :P2_EMP_ID


 OPTIONAL: Using URL Parameters

If you're manually building a URL or need to pass parameters programmatically:

f?p=&APP_ID.:2:&SESSION.::NO::P2_EMP_ID:&P1_EMP_ID.

This means:

* `f?p=`: APEX page call

* `&APP_ID.`: current app ID
* `2`: target page
* `&SESSION.`: session ID
* `P2_EMP_ID`: name of the item to set
* `&P1_EMP_ID.`: value from current page

Use this format in a **dynamic action** or PL/SQL-generated URL.

Best Practices

* Always validate that the receiving item (e.g., `P2_EMP_ID`) exists and has correct **Session State** enabled.
* Use **Before Header Process** on target page to act on parameter values.
* For security, avoid passing sensitive data via URL unless encrypted or obscured.

Here is a page with two fields and 1 button. We want to go to a second page and pass the values from the field in the URL.

A screen shot of a computer

Description automatically generated



In the Behavior area, select the redirect to URL and build the URL with the parameters included.

A black background with white text

Description automatically generated

Conclusion

Using button navigation with parameters in Oracle APEX allows you to create seamless, data-driven transitions between pages. By passing values through URL parameters or APEX items, you can control what information is available on the next page, enhancing the user experience and maintaining context throughout your app. As you've seen, this functionality is easy to implement and requires no complex coding—just clear configuration. With this technique, you’re now better equipped to build smarter, more responsive APEX applications.

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...