Oracle APEX - Hidden Substitution Strings

Oracle APEX (Application Express) is renowned for its ability to simplify and streamline web application development. While many of its features are well-documented and widely used, there are hidden gems within the framework that can take your APEX applications to the next level. In this blog post, we will explore the world of hidden substitution strings, focusing on how they can enhance your application's user experience and functionality.

Substitution Strings

Before we dive in, let's briefly explain what substitution strings are in Oracle APEX. Substitution strings are placeholders that you can insert into various parts of your application, allowing dynamic content replacement at runtime. They are incredibly versatile and can be used in SQL queries, PL/SQL code, text strings, and more.

Commonly used substitution strings include &APP_USER. (for the current user), &APP_ID. (for the application ID), and &APP_PAGE_ID. (for the page ID). These help personalise and adapt your application to user-specific contexts.

However, it's worth noting that there exist some lesser-known substitution strings that aren't as prominently highlighted in the documentation, but they hold the potential to significantly enhance your application. Let's embark on a journey to discover them.

1. #TIMING# - Measure Rendering Time

Performance matters in web applications. You can use the #TIMING# substitution string to display the time it takes to render a specific region. This is incredibly useful for optimising your application's performance and providing valuable feedback to users. You can use this substitution string in the Footer Text attribute of the region like this:

Footer text including substitution string TIMING.

2. Pagination Substitution Strings

If you're working with report regions, there are several hidden substitution strings tailored to pagination:

  • #ROWS_FETCHED#: This string shows the number of rows fetched by the reporting engine, which is often the page size. You can use it to craft customized messages for your users.
  • #TOTAL_ROWS#: Display the total number of rows that satisfy a SQL query used in your report. It's handy for showing users how many records are available, such as "Rows X - Y of Z."
  • #FIRST_ROW_FETCHED#: Use this to indicate the starting row in a paginated report, such as "Rows X - Y of Z."
  • #LAST_ROW_FETCHED#: This string represents the ending row in a paginated report, completing the "Rows X - Y of Z" format.

Again, these substitution strings are available for developers to use in the Footer Text attribute of the region.

Classic Report with custom pagination data using substitution strings

3. User's to #CUSTOMIZE# the interface

Did you know that APEX has a mechanism in place to that allows users to customise the rendering of specific regions on a page?

By default, end users are unable to customise the display attributes for regions. Nevertheless, developers have the option to grant users this freedom. APEX includes a built-in system to handle this, and it even stores the preferences for logged-in users, ensuring that the settings persist across sessions.

The standard region attribute "Customizable" offers 3 options:

  1. Not Customizable: Users can't customise attributes, ensuring consistency.
  2. Customizable, Default Shown: Users can customise attributes, with default settings.
  3. Customizable, Default Hidden: Users can customise attributes, but they aren't applied by default.
Oracle APEX - Standard Region Attribute Customizable

The less known #CUSTOMIZE# substitution string allows you to place the customize link in any place in your application. By default, the link will appear in the footer of any page template in Oracle APEX Universal Theme. Here is an example of the "Customize" link in the breadcrumb region.

Oracle APEX Sample Page with Customize link.

When users click on this link, a window will open, allowing them to display or hide regions on the page. This grants them greater control over their viewing experience.

Oracle APEX customize dialog

4. The Region Static ID

Specifying a static region ID in your Oracle APEX application can prove to be a valuable asset, particularly when you're working with custom JavaScript or cascading style sheets (CSS). This feature allows you to uniquely identify a region, making it easier to target specific regions for custom scripting or styling.

To assign a static region ID, simply navigate to the "Edit Region" page and utilise the "Static ID" attribute.

Oracle APEX - Standard Attribute Static ID

Once you've defined this ID, you can reference the region using the #REGION_STATIC_ID# substitution string within your region. This straightforward practice can streamline your development process and enhance the maintainability of your code.

Each region will generate its own unique ID whenever the #REGION_STATIC_ID# is used inside the HTML Source (for static regions), Header, or Footer Text attributes. For example, if you decide to include a <script> tag, you can dynamically reference the region's ID like this:

Oracle APEX - Sample footer text with javascript referencing the Static ID substitution string
⚠️
Note: As per HTML standards, these IDs must be unique across the entire page. So, be cautious to avoid any potential conflicts by ensuring that your static region ID doesn't collide with other IDs on the same page, such as buttons or other elements, to maintain valid HTML structure.

Conclusion

Oracle APEX's hidden substitution strings provide extra functionality that may be simply deployed and can take your application to the next level. They allow you to create more dynamic and user-friendly interfaces, improve performance, and offer valuable insights to your users.

So, the next time you're working on an APEX application, don't forget to explore these often overlooked features. Whether it's enhancing the footer of a region, measuring the rendering time, or customising pagination messages, hidden substitution strings are your powerful allies in building exceptional APEX applications.

Find out more about our APEX services