Loop through all page items in APEX

Search for a command to run...

No comments yet. Be the first to comment.
Building on the previous topic of leveraging Liquibase properties to modify APEX installations, we will delve into a companion technique. This one enables users to define as many property files as they wish in the artifact to set it when deploying. T...

Prereqs Latest SQLcl Existing SQLcl Project with an APEX app Note On average, I prefer to keep the same Schema name, APEX Application ID, Workspace Name, and Workspace ID across environments and have separate databases. I understand that this isn...

Situation Recently I was given a seed data file that was generated from SQLcl with a bunch of INSERT statements, and it worked fine in SQL Developer when ran but would fail in SQLcl with the following: SQL> @DEMO_DATA_TABLE.sql Error starting at lin...

There are plenty of good resources explaining how to create custom download links in APEX so I will skip over that part and list a couple here: - https://oracle-base.com/articles/misc/apex-tips-file-download-from-a-button-or-link - https://joelkallma...

Quick Tip for handling the merging of JSON in Oracle Database!

This blog has been sitting idle for too long. So starting off the New Year with a quick find!
Here is the problem:
We need to loop through all page items to apply some logic on demand, and preferably we want to do it dynamically.
Taking a look at apex.page there is a function called forEachPageItem.

Function
This is not documented in https://apex.oracle.com/jsapi but it is public. This returns a function. Here is the internal function signature and comment inside of page.js as of APEX 20.2:
// For the given form call callback once for each page item in that form. This includes disabled and unchecked items. // Page item elements are identified by having a name attribute that is not one of the well known names // input type=image not supported // See comments in ajaxSubmit as well function forEachPageItem( form$, callback, allElements )
Function Signature
It looks like can you pass a specific form as a parameter, but I am using what they use inside the page.js when the form parameter is null in other spots. This gives us back all page items on the page.
allItems = apex.page.forEachPageItem; allItems( $( "#wwvFlowForm" ), function( el, name ) { console.log(el); console.log(name); }, true );
Solution
Hope this can help someone as the majority of solutions I see online regarding this revolve already looking at the metadata views via PLSQL.