What Happens to APEX Page Items that are Never Rendered?

Every APEX page item has a Server Side condition which controls whether the item is rendered on the page. They're various server side condition options and for the purpose of this article we'll just set it to Never (can do things like queries that return a row, PL/SQL expressions, etc).

One misconception is that all references to this page item will be null / won't do anything. This is not correct as page items that aren't marked to be rendered can still have values. In the example below I have two page items:

  • P6_ALWAYS has no conditions and will always be shown on the page

  • P6_NEVER its condition will be set to Never and not render on the page

  • Both of the page items have a item source as a Function Body with the following code:

-- For always for P6_ALWAYS is "always" and P6_NEVER is "never"
logger.log('Source for always/never');
return 'always/never';

When the page is run it looks like:

Things to note:

  • P6_NEVER was not rendered

  • No values in session state (i.e. P6_ALWAYS item's value will only be saved in session state when the page is saved)

  • Looking at the logs only the P6_ALWAYS source code section was run

A new computation is now added to the page to set a value for P6_NEVER as shown below:

When the page is run it will look the same as before except that P6_NEVER has a value in session state. This means that when referencing P6_NEVER in a block of SQL or PL/SQL it will have a value, however if trying to reference it on the page (via JavaScript) it does not exists nor has a value.

In the past when I've explained this to people (both new and experienced APEX developers) and they think it's a bug. It isn't for the following reasons:

  • APEX has an order of operations. Essentially it runs "top down" for everything listed on the left side in Page Designer

  • Since Pre-Rendering is done before page items are "processed" APEX can't know if a page item should not be rendered

    • This can also be true of a page item's condition references another page ex. For example if a page item's condition is P6_ADMIN_YN = 'Y' then APEX will only know if this is true or false once it starts to process the page item.