plsqloracle-apexoracle23ai

Render page item which has HTML in Oracle Apex


I have an application where I need to display and stylize the heading of the region. So instead of display heading simply as "Car", I need to display "car icon Car". This icon and color etc are dynamic as in they will change as per model of the car.

What I was thinking is to generate the HTML for this heading via plsql based on sanitised inputs, store it in hidden page item and then use &P1_PAGE_ITEM. in the region title/heading attribute so that it will render in browser.

The issue I'm facing is, HTML is escaped in page items due to security purposes and there is no way of escaping it unlike report columns.

Is there any other way I can stylize the heading of the region conditionally?

I'm on Oracle Apex v24.2 and Oracle DB v23ai


Solution

  • There are a couple of escape filters available depending on the context a page item value with the &ITEM. notation is used in (hmtl, javascript, etc). The filter "RAW" displays the value "as is" without escaping any characters. Example:

    Page item P322_NEW has a computation to set it to <span class="u-danger-text u-fixedFont">Hello</span>

    enter image description here

    This shows in a static region with source

    enter image description here

    as:

    enter image description here

    For more complete info, look for "Controlling Output Escaping in Substitution Strings" in the docs