Search This Blog

Sunday, July 13, 2025

How do I Create a REST Data Source in APEX

 Introduction
Creating a REST Data Source in Oracle APEX allows you to easily integrate external RESTful web services into your applications. This capability lets you consume APIs to fetch, display, and manipulate data dynamically without needing to manage backend data synchronization manually. Leveraging REST Data Sources enables modern, flexible, and scalable application designs that can interact with various cloud services, third-party platforms, or internal APIs.

In APEX, a REST Data Source enables developers to seamlessly incorporate external RESTful web services or JSON data feeds into their applications. This functionality allows for the integration of external data into APEX components such as Classic Reports, Interactive Reports, Calendars, and JET Charts.

Types of REST Data Sources in APEX:

  • Simple HTTP: Designed for straightforward HTTP data feeds where all data is retrieved in a single request. This type assumes the server does not support advanced features like server-side filtering or ordering, requiring manual configuration of invocation details and parameters.

  • Oracle REST Data Services (ORDS): Targets REST services adhering to Oracle's REST standards, supporting standardized operations (GET, POST, PUT, DELETE). These services facilitate server-side filtering and ordering, allowing APEX to delegate report sorting and filtering to the REST service.

 How to Create a REST Data Source in Oracle APEX

  1. Access the REST Data Sources Section
    In Oracle APEX, navigate to the App Builder and open your application. From the shared components area, select "REST Data Sources." This is where you can define and manage REST endpoints for your app.

  2. Create a New REST Data Source
    Click "Create" and choose "From Scratch" or use the "From URL" option if you have the REST API endpoint URL ready. Enter a name for your REST Data Source and specify the base URL of the REST service you want to connect to.

  3. Configure Authentication and Headers
    If your REST API requires authentication (such as OAuth, Basic Auth, or API keys), configure these settings in the authentication section. You can add custom HTTP headers or query parameters necessary for your service.

  4. Define the Resource and Methods
    Specify the REST resource path and HTTP methods (GET, POST, PUT, DELETE) you intend to use. For a typical data retrieval, you will configure the GET method with optional query parameters.

  5. Test the REST Endpoint
    Use the built-in test functionality to verify that the REST Data Source is correctly configured and returning the expected data.

  6. Create REST Data Source Modules
    You can define multiple resource modules within the same REST Data Source to organize your API calls, supporting complex interactions.

  7. Use the REST Data Source in Your Application
    After setup, use the REST Data Source as a data source for reports, forms, or interactive grids within your Oracle APEX application. This enables real-time data fetching and updating through the REST API.

Best Practices

  • Always secure your REST Data Sources with appropriate authentication mechanisms.

  • Use pagination if the API returns large datasets to optimize performance.

  • Cache data when possible to reduce unnecessary calls.

  • Handle error responses gracefully in your application UI.

  • Keep your REST Data Source definitions organized and well-documented.

Oracle APEX Documentation
For detailed instructions and advanced configurations, refer to the official Oracle APEX REST Data Source documentation:
https://docs.oracle.com/en/database/oracle/application-express/

 

A screenshot of a computer

AI-generated content may be incorrect.

  • Click on REST Data Sources.

A screenshot of a computer

AI-generated content may be incorrect.

  1. Initiate Creation:

    • Click the Create button.

  • Choose From Scratch and proceed.

A screenshot of a computer

AI-generated content may be incorrect.

Conclusion
Creating REST Data Sources in Oracle APEX empowers developers to seamlessly integrate external APIs, expanding the capabilities of their applications. By following best practices and leveraging the built-in tools, you can build efficient, secure, and dynamic apps that consume real-time data from a variety of services. REST Data Sources are essential for modern APEX applications that require flexible data integration beyond the Oracle database.

How do I Create Enhance Tree Reports with JavaScript

 

Introduction
Enhancing Tree Reports in Oracle APEX with JavaScript allows you to add dynamic behaviors, improve user interactions, and customize functionality beyond the default capabilities. By leveraging JavaScript, you can create features such as custom node actions, dynamic styling, tooltips, and asynchronous data loading to provide a richer user experience. This blog explores how to use JavaScript effectively to enhance tree reports in Oracle APEX.

How to Create Enhanced Tree Reports with JavaScript in Oracle APEX

  1. Understand the Tree Report Structure
    Oracle APEX Tree Reports render using standard HTML elements and CSS classes. Use browser developer tools to inspect the tree structure and identify elements where you want to add JavaScript enhancements, such as node labels, icons, or expand/collapse controls.

  2. Add JavaScript to Your Page
    Navigate to the APEX Page Designer and open the page with the tree report. Use the "Execute when Page Loads" section or create a Dynamic Action of type "JavaScript" to insert your code. For example:

// Add a click event to tree nodes to display a custom alert
document.querySelectorAll('.a-TreeView-label').forEach(function(node) {
  node.addEventListener('click', function(event) {
    alert('You clicked on node: ' + event.target.textContent);
  });
});
  1. Implement Advanced Features

  • Custom Node Actions: Bind events to nodes to perform navigation or open modal dialogs.

  • Dynamic Styling: Change colors or icons based on node attributes or data.

  • Lazy Loading: Use AJAX calls to load child nodes dynamically for large trees.

  • Tooltips: Add informative tooltips on hover using libraries or custom code.

  1. Test Thoroughly
    Check that your JavaScript works across different browsers and devices. Use browser developer tools to debug errors and optimize performance.

Best Practices

  • Scope JavaScript selectors carefully to avoid affecting unrelated elements.

  • Keep code modular and maintainable by encapsulating logic in functions.

  • Avoid blocking the UI; use asynchronous calls when fetching data.

  • Use APEX APIs when available for better integration.

  • Document your code and changes for future reference.

Oracle APEX Documentation
For more details on Tree Reports and JavaScript integration, visit the official Oracle APEX documentation:
https://docs.oracle.com/en/database/oracle/application-express/

 

To automatically expand a specific node on page load, use the following JavaScript code in the Page JavaScript section:

apex.tree.expandNode('TREE_STATIC_ID', 3);

Replace TREE_STATIC_ID with your Tree Region Static ID and 3 with the node ID to expand.


Testing and Best Practices

  1. Run the page and verify that the tree loads correctly.

  2. Click different nodes to check if navigation works.

  3. Ensure large datasets use lazy loading to improve performance.

  4. If the tree structure does not display correctly, check the ID-PARENT_ID hierarchy in the table.


A Tree Report in Oracle APEX allows users to visualize hierarchical data interactively. By using SQL queries, navigation links, CSS styling, and JavaScript enhancements, you can create a powerful and user-friendly tree structure. This feature is particularly useful for organizational charts, file management systems, and category trees.


Tree Report EXAMPLE:


A screenshot of a computer

AI-generated content may be incorrect.


A screenshot of a computer

Description automatically generated

 

Conclusion
Using JavaScript to enhance Tree Reports in Oracle APEX unlocks powerful customization options, enabling you to build more interactive and user-friendly applications. By understanding the tree structure, carefully adding JavaScript, and following best practices, you can deliver sophisticated navigation components tailored to your users' needs while maintaining maintainability and performance.

How do I Add Styling the Tree with CSS

 

Introduction
Styling the Tree region in Oracle APEX using CSS allows you to customize the appearance to better match your application's branding and improve user experience. By applying CSS rules, you can change colors, fonts, spacing, icons, and hover effects, making the tree easier to navigate and visually appealing. This blog will guide you through the process of adding custom CSS styles to your tree components in Oracle APEX.

How to Add Styling to the Tree with CSS in Oracle APEX

  1. Identify the Tree Region CSS Classes
    Oracle APEX Tree regions use standard CSS classes such as .t-TreeView, .a-TreeView-node, and .a-TreeView-label for various elements. Inspect these elements using your browser's developer tools to understand which parts you want to style.

  2. Create Custom CSS
    Prepare your CSS rules targeting these classes. For example, to change the font color and add spacing, you might write:

.t-TreeView {
  font-family: Arial, sans-serif;
  font-size: 14px;
}

.a-TreeView-node {
  padding: 5px 10px;
}

.a-TreeView-label {
  color: #0055a5;
  font-weight: bold;
}

.a-TreeView-node:hover {
  background-color: #e0e7ff;
  cursor: pointer;
}
  1. Add CSS to Your APEX Application

  • Go to Shared Components > Cascading Style Sheets.

  • Click on "Create" and add your CSS in a new file or directly in Inline CSS in the Page or Application-level Inline CSS property.

  • Alternatively, you can add the CSS in the "Inline CSS" section of the page or in the application’s User Interface Attributes under the “CSS” property.

  1. Test and Refine
    Run your application, verify the styles are applied, and adjust as needed. Use browser developer tools to debug any style conflicts.

Best Practices

  • Scope your CSS to only affect the tree region to avoid unintended styling elsewhere; use region-specific selectors if needed.

  • Use consistent fonts and colors aligned with your application branding.

  • Test across different browsers and devices for compatibility.

  • Avoid overly complex CSS that may impact page load performance.

  • Document your CSS changes for future maintenance.

Oracle APEX Documentation
Refer to the official documentation for UI and theming here:
https://docs.oracle.com/en/database/oracle/application-express/

To improve the appearance of the tree, add custom CSS.

  1. Go to Shared ComponentsThemesCustom CSS.

  2. Add the following CSS code:

.a-TreeView .a-TreeView-node {

    font-size: 14px;

    padding: 5px;

}


.a-TreeView .a-TreeView-content:hover {

    background-color: #f4f4f4;

}


.a-TreeView .a-TreeView-content-selected {

    background-color: #0073e6;

    color: white;

}

Click Save and refresh the page.

 Conclusion
Customizing the appearance of tree regions with CSS in Oracle APEX empowers you to create intuitive and attractive navigation components tailored to your application's design standards. By carefully crafting and applying CSS, you enhance both the aesthetics and usability of your app. Following best practices and leveraging APEX’s flexible styling options ensures a maintainable and polished user interface.

How do I Add Navigation to the Tree Nodes

Introduction
Tree components in Oracle APEX provide a user-friendly way to represent hierarchical data such as file directories, organizational structures, or nested categories. Adding navigation to these tree nodes enhances user interaction by allowing users to click a node and open a related page, form, or report. In this blog post, we’ll explain how to add navigation to your tree nodes, enabling dynamic interaction and improving the usability of your application.

How to Add Navigation to Tree Nodes in Oracle APEX

To add navigation to a tree region, you need to ensure that the SQL query used in your tree includes a column with the target URL or page reference. Oracle APEX expects this value to be passed into the LINK pseudo column when defining the tree data source.

Step-by-Step Instructions:

  1. Open Your Tree Region
    Go to the Page Designer and select the Tree region you’ve created.

  2. Modify the Tree SQL Query
    Add a column in your query to define the navigation link. For example:

    SELECT 
      ID,
      PARENT_ID,
      NAME AS LABEL,
      'f?p=&APP_ID.:10:&SESSION.::NO::P10_ID:' || ID AS LINK
    FROM TREE_STRUCTURE
    

    In this example:

    • Page 10 is the target page.

    • P10_ID is the item on Page 10 that will receive the ID from the clicked node.

    • The LINK value constructs a URL using APEX's f?p= format.

  3. Update Tree Attributes
    In the Tree region settings:

    • Set "Link Column" to LINK

    • Set "Label Column" to LABEL

    • Set "ID Column" and "Parent Column" appropriately

  4. Test Navigation
    Run the page and click a node to confirm it redirects to the correct page with data passed through the link.

Best Practices

  • Always use f?p=&APP_ID. with proper session and security contexts.

  • Pass only needed parameters to keep URLs clean and maintainable.

  • Use friendly and readable labels in the tree for better UX.

  • Consider adding JavaScript or a dynamic action to intercept or enhance navigation if needed.

Oracle APEX Documentation
Official documentation for Tree Regions:
https://docs.oracle.com/en/database/oracle/apex/

 You can configure node clicks to open a details page for the selected department.

  1. In the Tree Attributes section, locate Node Link Target.

  2. Select Redirect to Page in this Application.

  3. Choose a Detail Form Page (e.g., a department details page).

  4. In Set Items, map the ID column to a page item (e.g., PXX_DEPT_ID).

  5. Save and run the page to test the navigation.

Conclusion
Adding navigation to tree nodes in Oracle APEX turns a static component into a powerful interactive tool. With a few adjustments to your SQL query and region settings, you can create intuitive, clickable trees that improve application flow and user experience. This small enhancement allows your users to explore data more naturally and makes your app more engaging and functional.

 

How do I Create a Table for Tree Data

Introduction
In Oracle APEX, working with hierarchical or tree-structured data often starts with designing the underlying database table appropriately. Whether you're building a tree report, organization chart, or category structure, a well-structured table is critical for enabling parent-child relationships. In this blog post, we’ll walk through how to create a table designed for tree data, explain the required columns, and offer tips for managing and querying hierarchical data effectively.

How to Create a Table for Tree Data

To support tree-based UI components in Oracle APEX, your table should include at least the following:

  • A unique identifier (ID) – Primary key for each row

  • A parent reference (PARENT_ID) – Self-referencing foreign key that defines the hierarchy

  • A label or name (NAME) – Human-readable name for display purposes

  • Optional: NODE_TYPE, ICON_CLASS, DESCRIPTION, or IS_LEAF – for advanced visualization or logic

Step-by-Step SQL to Create the Table:

CREATE TABLE TREE_STRUCTURE (
  ID          NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  PARENT_ID   NUMBER REFERENCES TREE_STRUCTURE(ID),
  NAME        VARCHAR2(100) NOT NULL,
  DESCRIPTION VARCHAR2(4000),
  CREATED_AT  TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Insert Example Data:

INSERT INTO TREE_STRUCTURE (NAME, PARENT_ID) VALUES ('Root Node', NULL);
INSERT INTO TREE_STRUCTURE (NAME, PARENT_ID) VALUES ('Child A', 1);
INSERT INTO TREE_STRUCTURE (NAME, PARENT_ID) VALUES ('Child B', 1);
INSERT INTO TREE_STRUCTURE (NAME, PARENT_ID) VALUES ('Sub-child A1', 2);

This example creates a simple 3-level hierarchy:

  • Root Node
    ├── Child A
    │   └── Sub-child A1
    └── Child B

Best Practices

  • Ensure ID is a primary key and PARENT_ID references the same table to maintain integrity.

  • Use indexed columns on PARENT_ID for better performance in CONNECT BY queries.

  • Avoid circular references by validating data before inserts or updates.

  • Use a VIEW to add virtual columns such as full path, depth, or breadcrumb if needed.

Oracle APEX Documentation
For more information on working with tree data and reports, visit:
Oracle APEX Tree Region Documentation

 

Before creating the report, ensure that your table follows a hierarchical structure. The table should have at least two key columns:

  1. ID – The unique identifier for each node.

  2. PARENT_ID – The reference to the parent node.

Example table structure:

CREATE TABLE DEPARTMENT_HIERARCHY (

    DEPT_ID      NUMBER PRIMARY KEY,

    DEPT_NAME    VARCHAR2(100),

    PARENT_ID    NUMBER REFERENCES DEPARTMENT_HIERARCHY(DEPT_ID)

);

Sample data:

INSERT INTO DEPARTMENT_HIERARCHY VALUES (1, 'Corporate', NULL);

INSERT INTO DEPARTMENT_HIERARCHY VALUES (2, 'Finance', 1);

INSERT INTO DEPARTMENT_HIERARCHY VALUES (3, 'HR', 1);

INSERT INTO DEPARTMENT_HIERARCHY VALUES (4, 'Payroll', 2);

INSERT INTO DEPARTMENT_HIERARCHY VALUES (5, 'Recruitment', 3);

COMMIT;


Creating a Tree Report in Oracle APEX

  1. Go to Oracle APEX and navigate to your application.

  2. Click CreatePageReportTree.

  3. Select Use a SQL Query as the data source.

  4. Enter the SQL Query for the tree structure:

SELECT 

    DEPT_ID AS ID,

    PARENT_ID AS PARENT_ID,

    DEPT_NAME AS NAME

FROM DEPARTMENT_HIERARCHY

  1. Click Next, configure the report settings, and click Create.

After creating the tree, you can customize how it appears and behaves.

Configuring Tree Attributes

  1. Open Page Designer and select the Tree Region in the Rendering Pane.

  2. Modify the following attributes under the Tree Attributes section:

    • Icon Column: Specify an icon for nodes (e.g., fa-folder for parent nodes).

    • Expand All: Enable this if you want the tree fully expanded by default.

    • Lazy Loading: Set this to Yes if working with large datasets to improve performance.

    • Selection Type: Choose Single Selection if you want users to select only one node.

Conclusion
Creating a table that supports tree data in Oracle APEX involves a simple yet structured approach. By establishing a self-referencing schema with proper constraints and meaningful attributes, you set the foundation for effective tree visualizations. With this setup, you can build dynamic tree reports, enable drill-down features, and maintain hierarchical clarity within your APEX applications.

 

How do I Create a Tree Report in Oracle APEX

 

Introduction
Creating a Tree Report in Oracle APEX is a powerful way to display hierarchical data such as organization charts, category breakdowns, or file structures. The Tree Region in APEX allows you to visually represent parent-child relationships using an intuitive and interactive tree view. In this blog post, we’ll walk through how to create a Tree Report, define the necessary SQL query, and configure the region attributes to present your data in a meaningful and user-friendly way.

How to Create a Tree Report in Oracle APEX

  1. Prepare Your Data
    Before you begin, ensure your table contains at least:

  • A unique identifier (e.g., ID)

  • A parent identifier (e.g., PARENT_ID)

  • A label (e.g., NAME)

Your data must form a hierarchy, where each row references a parent row.

  1. Create a Tree Region

  • Navigate to your page in Page Designer.

  • Click the + icon to add a new region.

  • Choose Tree under the “Reports” section.

  1. Configure the Tree Region Source
    Use a hierarchical SQL query with the CONNECT BY clause:

SELECT 
  ID, 
  PARENT_ID, 
  NAME AS LABEL 
FROM 
  TREE_TABLE
START WITH 
  PARENT_ID IS NULL
CONNECT BY 
  PRIOR ID = PARENT_ID

Map these values in the region’s Attributes section:

  • Node ID ColumnID

  • Parent Node ColumnPARENT_ID

  • Node Label ColumnNAME or a derived label

  1. Set Node Icons (Optional)
    If your table contains a column for icons or if you want conditional icons, use the Node Icon Column setting. You can return class names like 'fa fa-folder' or use the APEX icon library.

  2. Add Links or Actions (Optional)
    You can define a Link Target so that clicking on a node opens a specific page (such as a detail form). Use column substitutions like:

f?p=&APP_ID.:10:&SESSION.::NO::P10_ID:#ID#

This navigates to page 10 and passes the selected node's ID to P10_ID.

Best Practices

  • Limit the depth of the tree if your dataset is large—consider using lazy loading with dynamic actions if needed.

  • Make sure your parent-child relationships do not contain cycles, or the tree will fail to render.

  • Use descriptive labels and clear icons to improve usability.

  • Consider using a REST-enabled SQL source or a view for performance optimization and cleaner design.

Oracle APEX Documentation
For additional configuration options and advanced use cases, refer to:
Oracle APEX Tree Region Documentation

 

A Tree Report in Oracle APEX provides a structured way to display hierarchical data, such as organizational charts, category structures, or folder directories. This tutorial explains how to create, configure, and customize a Tree Report in APEX.


Understanding Tree Reports

A Tree Report is used to display parent-child relationships in a hierarchical format. It consists of:

  • Node (Parent Item): The main category or entity in the hierarchy.

  • Child Nodes (Sub-items): The subcategories or records linked to the parent.

  • Tree Structure: Expanding and collapsing nodes dynamically.

Tree Reports are best used when data follows a hierarchical structure, such as departments and employees, product categories and subcategories, or folders and files.

Conclusion
The Tree Region in Oracle APEX is a versatile and elegant solution for presenting hierarchical data structures. With proper setup of your data and careful configuration of region attributes, you can deliver an intuitive visual experience to your users. Whether you're organizing categories, departments, or nested items, APEX Tree Reports help bring structure and clarity to your applications.

UI Defaults

 In Oracle APEX, User Interface (UI) Defaults are a set of metadata-driven, table- and column-scoped attributes that APEX consults when it g...