Oracle APEX - Set Item Read-Only Plugin

Sharing a Dynamic Action plugin to Set Item(s) to Read-Only. It supports both IG Column Items as well as regular Page Items. There is a corresponding Unset plugin.
APEX has Dynamic Actions for Disabling/Enabling Items. Fundamental difference to a Read-Only item is, a disabled item is considered as not relevant, not applicable. Subsequently, any value is grayed out, it is not receiving focus, it is not recognized by Screen readers, the value is not submitted, there is no constraint validation, etc. Read-Only items to the contrary have there values just relevant, though UI interaction is blocked. A well known example is a (dynamically) calculated total value. The value is not grayed out, instead the styling is adjusted in a different way. A screen reader will mention the value and the fact it is read-only. A read-only item also typically has it’s value ready to be copied into the clipboard.
An item can be (conditionally) marked as Read-Only in APEX.
This is a server-side construct. Server-side, a Display Only item will be generated with a checksum. Client-side, you can not programmatically adjust the value as it would give a session state protection violation error. The item is not marked in html as Read-Only in any way, and though screen readers will read the value upon hovering, that will be all. These items also will not receive focus.
For Interactive Grid, there is an ‘is-readonly’ class available, which can be utilized for the grid. It won’t have any impact on the single row view though. Another way to make columns read-only is by making use of the model recordfield metadata ck property. This will work for both the grid as well as the single row view. It will completely block the item, so also programmatically, and ‘display only’ items are used in the single row view.
Using the plugin, you can dynamically set/unset the read-only mode of items. UI interaction is blocked, programmatically though the value can be adjusted. Values are submitted - do take care of any needed validation/recalculation server-side. Screen readers will mention the item as read-only. HTML offers a readonly setting for the html element behind Text, Number and Textarea item, so that one will be utilized. For other item types like Select, Checkbox, Popup LOV, Date Picker, Radio Group, etc, the plugin will block buttons, events, popup’s, etc as to achieve the read-only mode. The styling of Read-Only items also will be adjusted, equal to how APEX handles this for Display Only items with a dashed border and background color equal to the region background color. For Accessibility, there is a ‘aria-readonly’ attribute available in html, but it proved out that one is hardly having any effect, especially not with Firefox. So instead, the plugin will add an ‘aria-describedby’ attribute.
There is also support for Items in Interactive Grid. Upon a row getting into edit mode, it shows like this (address columns read-only), click to enlarge:
and the corresponding single row view like this:
And that makes up the functionality of the RO plugin. If you want to have a further look, here is an example page.
Subscribe to my newsletter
Read articles from Karel Ekema directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Karel Ekema
Karel Ekema
Application Developer, applying Oracle APEX to develop Data-Centric, Workflow, BPM and Case Management applications.