Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why doesn’t Display Image refresh when its source item changes? It consistently shows the previous value

KISS TIBOR10 hours ago — edited 6 hours ago

🧩 Why doesn’t Display Image refresh when its source item changes? It consistently shows the previous value

In Oracle APEX, I ran into a persistent issue: a Display Image item linked to an item like P14_MAIN_PICTURE_URL did not update when the item value changed. Even though the new value was correctly set and visible in session state, the image kept showing the previous value.

🧪 JavaScript workaround — partially effective

Using JavaScript to manually update the image worked in most cases:

$("#P14_MAIN_PICTURE").attr("src", apex.item("P14_MAIN_PICTURE_URL").getValue());

However, this failed on the first page load after authentication. The image didn’t appear at all, and the DOM didn’t contain the <img> tag — even though the item had a valid value. The issue persisted until the page was manually refreshed.

🔍 Root causes (two separate issues)

1. The Display Image item does not render into the DOM if its source item is null or empty during server-side page rendering.
→ No <img> tag is generated, so JavaScript cannot update it later.

2. The “Refresh” action does not work for Display Image items.
→ Even if the item value changes, APEX does not re-evaluate the substitution string or re-render the image. Oracle confirms that not all item types support refresh:

“Page items cannot be ‘refreshed’ — their values can be set by source attribute, default value attribute, computation or page processes. Those are all pre-rendering actions in APEX, they cannot be ‘redone’ once the page is rendered.”
Koen Lostrie on Stack Overflow

✅ Solutions for both issues

To ensure the image renders into the DOM:

  • Set a default value for the source item (P14_MAIN_PICTURE_URL)
    → e.g. https://via.placeholder.com/1x1.png
    This guarantees the item is never null during initial rendering.

To ensure the image updates when the item value changes:

  • Add a Dynamic Action on the source item (**P14_MAIN_PICTURE_URL**)
    • Event: Change

    • Action: Execute JavaScript Code

    • Code:

      $("#P14_MAIN_PICTURE").attr("src", apex.item("P14_MAIN_PICTURE_URL").getValue());
      

This setup ensures that the image element exists from the start, and that it updates correctly when the source item changes. Refreshing the item or region alone will not work for Display Image components.

Comments
Post Details
Added 10 hours ago
0 comments
44 views