Search This Blog

Friday, July 18, 2025

Using a Badge in Oracle APEX

 In Oracle APEX, badges are small visual indicators typically used to highlight numeric values, such as counts, statuses, or notification indicators. They are especially useful when you want to quickly draw attention to a value in reports, lists, cards, or even button labels. APEX makes it easy to integrate badges into your UI using built-in templates or manually with HTML and CSS. This blog explains how to use badges in various ways inside your APEX applications.

How to Use a Badge in Oracle APEX

There are several methods to display a badge, depending on the region type and use case. Here are the most common ways:

1. Badge in a Classic Report or Interactive Report

To show a badge inside a report, you can use HTML in your SQL query.

Example:

SELECT 
  EMPLOYEE_NAME,
  DEPARTMENT,
  '<span class="t-Badge t-Badge--success">' || PROJECT_COUNT || '</span>' AS PROJECTS
FROM EMPLOYEES

Steps:

  • In the column where you want to display the badge (e.g., PROJECTS), write a SQL expression that wraps the value with a <span> tag and the t-Badge class.

  • In Page Designer, select the column and set Escape Special Characters to No to render the HTML.

2. Badge on a Button

You can also show a badge on a button label, often for notifications or counts.

Steps:

  • Edit the Button Label to include the badge HTML.

Example:

Notifications <span class="t-Badge t-Badge--warning">3</span>

3. Badge in a List or Card Report

When using lists or cards, Oracle APEX offers Badge settings as a native feature.

For Lists:

  • Go to Shared Components > Navigation Menu (or other list)

  • Edit the List Entry.

  • Use the “Badge Value” attribute to enter a number or expression.

  • You can set “Badge CSS Classes” like t-Badge--success, t-Badge--warning, t-Badge--info.

For Cards:

  • When using a Card Region, set the Badge Value in the Attributes tab.

  • Customize the Badge Appearance (Color and Position) using predefined styles.

Badge Classes:
Here are some of the most used built-in classes for APEX badges:

  • t-Badge--success (green)

  • t-Badge--warning (yellow)

  • t-Badge--info (blue)

  • t-Badge--danger (red)

  • t-Badge--primary (default)

  • t-Badge--pill (adds rounded edges)

Best Practices

  • Use badges for small, focused numeric or status indicators—avoid using them for long text.

  • Always set “Escape Special Characters” to No only if you're generating trusted HTML content.

  • For dynamic badges (e.g., unread messages), use PL/SQL or SQL queries that update the value in real-time.

  • Use consistent colors across the application to avoid confusing users (e.g., green always means success).

  • Avoid overusing badges—they should highlight key data, not overwhelm the interface.


Badges are used in reports to display statuses, usually single words such as : Pending, Closed, and Open.


Interactive Report

A person holding a hand

Description automatically generated with medium confidence

Query:

Query:

select ID,

       TASK_NAME,

       START_DATE,

       END_DATE,

       STATUS,

       ASSIGNED_TO,

       COST,

       BUDGET,

       case STATUS

         when 'Closed'  then 'success'

         when 'Open'    then 'danger'

         when 'Pending' then 'warning'

         else 'info'

       end as BADGE_STATE,

       case STATUS

         when 'Closed'  then 'fa-check'

         when 'Open'    then 'fa-exclamation'

         when 'Pending' then 'fa-question'

         else 'fa-info'

       end as BADGE_ICON

  from EBA_UT_CHART_TASKS



Now, make the following changes to the following

Badge State:

A black rectangular object with a black stripe

Description automatically generated

A black and white line

Description automatically generated with medium confidence

A screenshot of a computer

Description automatically generated

Badge Icon:

A black rectangular object with a black stripe

Description automatically generated

A black and white text

Description automatically generated

A screenshot of a computer

Description automatically generated

A screenshot of a computer

Description automatically generated


Here’s a complete SQL example you can use in an Oracle APEX Classic or

Interactive Report to demonstrate how to use a badge (label with color) for the status column using Oracle APEX's "HTML Expression" or "Column Formatting" options.

More Example:

Classic Report


A black and grey striped object

Description automatically generated

A screenshot of a computer

Description automatically generated

Query:

select ID,

       TASK_NAME,

       START_DATE,

       END_DATE,

       STATUS,

       ASSIGNED_TO,

       COST,

       BUDGET,

       case STATUS

         when 'Closed'  then 'success'

         when 'Open'    then 'danger'

         when 'Pending' then 'warning'

         else 'info'

       end as BADGE_STATE,

       case STATUS

         when 'Closed'  then 'fa-check'

         when 'Open'    then 'fa-exclamation'

         when 'Pending' then 'fa-question'

         else 'fa-info'

       end as BADGE_ICON

  from EBA_UT_CHART_TASKS






Here is this result:


Make these changes to Badge-State column


A screenshot of a computer

Description automatically generated

A screenshot of a video game

Description automatically generated

{with/}

LABEL:=STATUS

VALUE:=#STATUS#

STATE:=#BADGE_STATE#

ICON:=#BADGE_ICON#

LABEL_DISPLAY:=N

STYLE:=t-Badge--subtle

SHAPE:=t-Badge--circle

{apply THEME$BADGE/}


SQL Query (with HTML for Badge on status, displaying other statuses)

SELECT 
    task_name,
    TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date,
    TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date,
    
    -- Status with HTML badge
    CASE status
        WHEN 'Completed' THEN '<span class="t-Badge t-Badge--success">Completed</span>'
        WHEN 'In Progress' THEN '<span class="t-Badge t-Badge--info">In Progress</span>'
        WHEN 'Pending' THEN '<span class="t-Badge t-Badge--warning">Pending</span>'
        WHEN 'Overdue' THEN '<span class="t-Badge t-Badge--danger">Overdue</span>'
        ELSE '<span class="t-Badge">Unknown</span>'
    END AS status_badge,

    assigned_to,
    TO_CHAR(cost, 'FM$999,999.00') AS cost,
    TO_CHAR(budget, 'FM$999,999.00') AS budget

FROM tasks;

 What You Need to Do in APEX

  1. Go to your Report Region (Classic or Interactive Report)

  2. Use the SQL above

  3. In Column Attributes:

    • Hide the original status column if you’re using a separate status_badge

    • For status_badge, set:

      • Escape special characters:  Uncheck (very important so APEX renders the HTML)

 Available Badge CSS Classes in Oracle APEX

You can use these built-in badge classes:

Status CSS Class
Success t-Badge--success
Info t-Badge--info
Warning t-Badge--warning
Danger t-Badge--danger
Default/Gray t-Badge

Tips

  • Keep status values standardized (avoid spelling issues like complete, Complete, COMPLETED)

  • Consider using status as a LOV or ENUM to reduce data inconsistency

  • Use Tooltips or colors for accessibility if used heavily



Oracle APEX Documentation

You can read more about badges in Oracle APEX UI components at:
https://docs.oracle.com/en/database/oracle/apex/

Conclusion

Badges in Oracle APEX are a simple but powerful way to improve the visual impact of your application. Whether in reports, lists, cards, or buttons, they help your users quickly identify important values or statuses. By using HTML, native attributes, or template options, you can control how and where badges appear, and style them consistently to align with your application’s design and purpose.

How to Manually Add a Link to a Classic Report in Oracle APEX

 In Oracle APEX, Classic Reports provide a flexible way to present data using SQL queries. One common requirement is to include a manual link in the report—such as a "View", "Edit", or "Details" link—so that users can navigate to another page, pass values, or trigger actions. While Oracle APEX provides built-in options for adding links through column attributes, manually adding a link gives you greater control over the output and behavior. This blog post explains how to manually add a link to a Classic Report using SQL and HTML, complete with best practices and examples.

How to Do It: Step-by-Step

  1. Create or Edit a Classic Report Region
    Navigate to your APEX app and create a new Classic Report page, or open an existing one.

  2. Edit the SQL Query
    Modify the SQL query of the Classic Report to include a column with the desired link using HTML anchor (<a>) tags.

    Example:

    SELECT 
      EMPLOYEE_ID,
      FIRST_NAME,
      LAST_NAME,
      '<a href="f?p=&APP_ID.:10:&SESSION.::NO::P10_EMPLOYEE_ID:' || EMPLOYEE_ID || '">View</a>' AS EMP_LINK
    FROM EMPLOYEES
    

    This example creates a "View" link that navigates to Page 10 and passes the EMPLOYEE_ID as a value to page item P10_EMPLOYEE_ID.

  3. Set Column Type to "Standard Report Column"
    In Page Designer, select the EMP_LINK column in the report. In the Property Editor, set the "Escape Special Characters" option to No so the HTML anchor tag is rendered correctly in the browser.

  4. Configure Target Page (Optional)
    On the target page (Page 10 in the example), make sure P10_EMPLOYEE_ID is configured to receive the value via a page item or process.

Best Practices

  • Always validate and sanitize dynamic values (e.g., EMPLOYEE_ID) to prevent injection attacks.

  • Set “Escape Special Characters” to No only for columns where you control the output and have added safe HTML.

  • Use f?p syntax for links when navigating within APEX applications to preserve session context.

  • Consider using dynamic actions or link icons if users expect a more interactive experience.

  • Keep page and item names consistent to simplify debugging and maintenance.

Useful Variations

  • Open the target page in a dialog:

    '<a href="javascript:apex.navigation.dialog(' ||
    '''f?p=&APP_ID.:10:&SESSION.::NO::P10_EMPLOYEE_ID:' || EMPLOYEE_ID || ''');">View</a>' AS EMP_LINK
    
  • Add multiple links (Edit, Delete):

    '<a href="f?p=&APP_ID.:10:&SESSION.::NO::P10_EMPLOYEE_ID:' || EMPLOYEE_ID || '">Edit</a> | ' ||
    '<a href="f?p=&APP_ID.:11:&SESSION.::NO::P11_EMPLOYEE_ID:' || EMPLOYEE_ID || '">Delete</a>' AS ACTIONS
    


Step 1 – We’re starting with an CUSTOMER table with 3 columns

  • Customer_ID

  • Full_Name

  • Email_Address

Step 2 – We are going to create a blank page with a custom report in it, added manually.

In this case is called: ClassicReport_ReportPage

Step 3 – Add region to the page and change it to a type of: Classic report Region. and wire it up to the Customer data table.

A screenshot of a computer

Description automatically generated

Step 4 – In the Classic report, navigate to the “Columns”, right click, and select “Add virtual column”.


Step 4 – Make the following changes

A screenshot of a computer

Description automatically generated

Step 5 – Lets create the Form that will receive our data. Create a Form.


A screenshot of a computer

Description automatically generated

Select the primary Key

A screenshot of a computer

Description automatically generated

You should now have something like this

A screenshot of a computer

Description automatically generated

Notice that in this case P41_CUSTOMER_ID is the key of the table

Step 6 – Go back to the Classic Report page. In this case it happens to be page 40 and our form page is page 41.

Navigate to the Link column and Edit the LINK area and click on the button.

  A black box with red lines and white text

Description automatically generated

Step 7 – Add the page number of the Form page (in this case is 41) and in the “Set Items” area, click on the hamburger list button.

Select the item that you want to pass “to” the Form page, in this  P41_Customer_ID

A screenshot of a computer

Description automatically generated

Next select the Value that you want to pass. In this case the CUSTOMER_ID column’s value (the table’s primary key)

A screenshot of a computer

Description automatically generated

It should now look like this.

A screenshot of a computer

Description automatically generated

Save the page and view in the browser.

We now have a page with a column but no actual link

A screenshot of a email

Description automatically generated

Step 8 –

In the link area, in the Link Text, enter a name, save, and review in browser.


Your page should now have a link that will navigate to the Form page

Step 9 – lets change to the words into a link. Select the hamburger next to the LinksText area and click on the fa-edit icon selection (or one of the other options) and save and review in browser.


You now have a navigational icon for the link area


Documentation

You can read more on Classic Report customization and column linking in the official APEX documentation:
https://docs.oracle.com/en/database/oracle/apex/

Conclusion

Manually adding a link to a Classic Report in Oracle APEX is a simple yet powerful technique. It allows for full control over how users interact with your data, particularly when the default column link settings don't meet your needs. By using HTML inside SQL queries and configuring your report settings correctly, you can create dynamic, user-friendly applications that respond precisely to user actions.

TYPES OF REPORTS in ORACLE APEX

 Cards Report

A cards page consists of individual boxes, which resemble index cards, laid out on a page. Each card displays three pieces of information: Card Title, Description Column, and Additional Text Column. First, you select a table or view on which to build the page. Second, you select the Card Title, Description Column, and Additional Text Column.

  • Display data at a glance using information tiles that can easily include an image.

  • Choose between three cards page layouts: Grid, Float, or Horizontal (Row).

  • Provides summary information from a modern layout with one-click access to more details on another report or form page.

A cards page features an orderly layout of information tiles. Developers choose between three layouts: Grid, Float, or Horizontal (Row).

Features:

  • Customize every aspect of a cards region's UI (including layout, appearance, icon, badge, and media).

  • Declaratively create links from a cards page by adding actions. Action types include Button, Full Card, Title, Subtitle, or Media.

  • Supports advanced HTML expressions including template directives for client-side conditional formatting.

A cards page features an orderly layout of information tiles. Developers choose between three layouts: Grid, Float, or Horizontal (Row).

Features:

  • Customize every aspect of a cards region's UI (including layout, appearance, icon, badge, and media).

  • Declaratively create links from a cards page by adding actions. Action types include Button, Full Card, Title, Subtitle, or Media.

  • Supports advanced HTML expressions including template directives for client-side conditional formatting.

Classic Report

  • Display data in a simple report region.

  • Update data by including a report and update form combination during creation.

  • Column sorting configurable.

A classic report features a simple report page based on the formatted result of a SQL query.

Features:

  • Report can display as a standard application page or as a modal dialog.

  • Enable the Include Form option to create a report and update form combination.

  • Enable column sorting in Page Designer by selecting a column and configuring Column, Sorting attributes.

  • The most versatile report as it is template-driven. Choose from the predefined report templates, including Media List, Comments, Timeline, Badge List, Value Attributes Pairs, and so on. Or, create your own template to customize and visualize data.

  • Download the report as a CSV, HTML, Excel, or PDF.

  • Supports Report Layouts to format PDF exports.

Limitations compared to other report types:

  • Using templates requires changing the SQL query column names to match the chosen template (for row templates)

  • No support for scroll pagination or virtual scrolling. Other pagination options available.

  • No column header groups, frozen columns, and template directives.


Faceted Search Report

  • Display and filter data using an intuitive experience users recognize from ecommerce sites (a left Search region and report region).

  • Show search results as cards or a classic report.

  • Includes built-in search capability.

  • Users select facets in the Search region to narrow down the search results.

A faceted search page displays and filters data using an intuitive experience users recognize from ecommerce sites (a left Search region and report region). The report region displays search results as cards or a classic report.

  • Features:

  • Select options from facets in the left Search region to narrow down search results.

  • Set filters using facets that show possible values together with the occurrence count within the result set.

  • Built-in search capability.

  • Optionally include a chart for any facet.

  • Toggle between a bar chart (which is the default) and pie chart type.

  • Create facet groups for data models having multiple flag columns.


Interactive Grid Report

  • Display data in a searchable, customizable report that supports inline editing at runtime using the mouse or keyboard.

  • Enable end users to create highly customized reports. Users can alter the report layout by using either the Column Heading menu or Actions menu.

  • Move columns by using the Actions menu, Column dialog, or by dragging and dropping with the mouse.

  • Save customizations and report layout by saving a private or alternative report just for yourself, a public report, or as a primary report that can be viewed by others.

  • Save a report layout by creating an Alternative or Private report.

  • Download or email the report as a CSV, HTML, PDF, or Excel file.

  • Enable and disable editing capability at by editing attributes in Page Designer.

  • If editable:

  • Select options from the Row Action menu.

  • Add and remove rows or edit data by directly editing a cell.

An interactive grid presents data in a searchable, customizable report. Includes similar customization capabilities available in interactive reports plus the ability to rearrange the report interactively using the mouse or keyboard.

Features:

An interactive report page features a searchable, easily customizable report.

Features:

  • Report can display as a standard application page or as a modal dialog.

  • Enable the Include Form option to create a report and update form combination.

  • Built-in search capability.

  • Extensive customization capabilities using menus or inline editing.

  • Turn editing on or off using the region Attribute, Edit, Enabled.

  • Built-in search capability.

  • For both editable and non-editable reports, users can change the report layout and create private reports:

    • Column Heading menu - Change the report layout with Control Break, Aggregations, Freeze, Hide, and Filter.

    • Actions menu:Columns - Configure the columns to show or hide.

      • Filters - Create filters to alter the display.

      • Data - Sort, Aggregate, Refresh, Flashback.

      • Format - Control Break, Highlight, Stretch Column Widths.

      • Selection - Cell Selection, Copy to Clipboard, Refresh Rows.

      • Chart - Create chart.

      • Report - Create, edit, and manage saved Private or Alternative reports.

      • Download - Download or email the report as a CSV, HTML, PDF, or Excel file

If editable, users can edit the data directly:

  • Row Actions menu - Single Row View, Add Row, Duplicate Row, Delete Row, Refresh Row, Revert Changes.

  • Add Rows - Add new rows by clicking the Add Row button.

  • Edit Rows - Edit a row by selecting or double-clicking a cell with the mouse, editing the content, and clicking the Save button.

Limitations compared to other report page types:

  • Rows are fixed height. No variable height option.

  • Does not remember current page.

  • Tabular form limitations: submit selected rows, always edit for small number of records

  • Interactive report features not supported: Pivot view, Group By view, Computed columns, and complex filters.

Change the report layout and create private reports using menus:

Column Heading menu: Change the report layout with Sort Ascending, Sort Descending, Hide Column, Control Break, and Filter.




Actions menu:

  • Columns - Configure the columns to show or hide.

  • Filters - Create filters to alter the display.

  • Data - Sort, Aggregate, Compute, Flashback.

  • Format - Control Break, Highlight, Rows Per Page.

  • Chart - Create a chart.

  • Group By - Group sets of results by one or more columns with Group By.

  • Pivot - Pivot reports transpose rows into columns to generate results in a cross tab format.

  • Report - Create, edit, and manage saved Named reports.

  • Download - Download or email the report as a CSV, HTML, Excel, or PDF.

  • Subscription - Subscribe to report updates in CSV, HTML, Excel, or PDF format.

Limitations compared to other report page types:

  • No scroll pagination.

  • Freeze columns not supported.

  • Column groups not supported.

  • Charts not as powerful as interactive grid.

Smart Filter Report

A smart filters page features a single search field at the top of the page and a search results report (classic report, cards, map, or calendar). While a smart filter behaves similarly to faceted search, it features a more space efficient layout.

Features

  • Display data using a single search field region at the top of the page and results report.

  • Offers a more compact UI when compared to faceted search.

  • Search results report can display as a classic report, cards, map, or calendar.

  • End users select filters that display as suggestion chips.

  • Includes built-in search capability.

  • Configurable search suggestions

  • Display data using a single search field region at the top of the page and results report.

  • Offers a more compact UI when compared to faceted search.

  • Search results report can display as a classic report, cards, map, or calendar.

  • End users select filters that display as suggestion chips.

  • Includes built-in search capability.

  • Configurable search suggestions

  • Includes a search field at the top of the page with filters that display as suggestion chip.

  • The Search Results can display as a classic report, cards, map, or calendar.

  • Clicking a filter name displays a list of values.

  • Clicking to right of a suggestion chip changes it to an applied filter chip and moves to the Applied Filters Area. Clicking the applied filter chip again displays a list.

  • Built-in search capability.

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