rules repository

A-3160 Try to give regions an HTML DOM ID.

Severity Info Check + SQL-based Test Free New

Reason

Without an explicit HTML DOM ID, APEX generates the DOM id of the region from the internal region id (R1234567890). JavaScript (apex.region("…")), CSS and dynamic actions with a jQuery selector that address the region then depend on a number that changes when the page is copied or the app is imported into another workspace. (Dynamic actions with selection type Region are not affected.)

Set the region's HTML DOM ID to its Static ID: every region has one since APEX 26.1, and it is already unique on the page, so there is no new name to invent. Regions that are never addressed from JavaScript or CSS can do without one.

Example

Non-Compliant Example

page 10 (
    // ...
    region orders (
        name: Orders
        type: staticContent
        // ...
        // no htmlDomId
    )
)
Issues
LineColumnMessage
312Region has no HTML DOM ID.

Compliant Solution - ★★★★★

page 10 (
    // ...
    region orders (
        name: Orders
        type: staticContent
        // ...
        advanced {
            htmlDomId: orders
        }
    )
)

Tests

Test SQL query

select aa.workspace || '.' || aa.alias || '.' || r.page_id || '.' || r.region_static_id as identifier,
       'Region ' || r.region_name || ' on page ' || r.page_id || ' of app ' || aa.alias || ' in ' || aa.workspace
         || ' has no HTML DOM ID.' as message
  from apex_application_page_regions r
  join apex_applications aa
    on aa.application_id = r.application_id
       and aa.workspace = r.workspace
 where aa.workspace in (#ApexWorkspaces#)
   and r.html_dom_id is null

Test results

IdentifierMessageMigration
WORKSPACE.CUSTOMERS.10.ordersRegion Orders on page 10 of app CUSTOMERS in WORKSPACE has no HTML DOM ID.-

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
ApexWorkspacesComma-separated List of APEX workspaces owning APEX applications to check.dblinter, dbl_gui

References