Complex Region Type Plug-ins might render their own input fields, like our Interactive Report component does with the search field. If a developer had set the page level attribute Cursor Focus to First item on Page in Oracle APEX 4.x, it only affected Page Items but not those region input fields.
We thought that definitely provides room for improvement, because it would be great if the search field of an Interactive Report could automatically get keyboard focus. And because we want to provide you the same capabilities as our own native components, this new feature has been added to the Plug-in framework.
To let the APEX Runtime Engine know about a focusable input field of a region type plug-in, you can set the new
navigable_dom_id attribute in the record type
apex_plugin.t_region_render_result which is returned by your region plug-in rendering function.
type t_region_render_result is record ( navigable_dom_id varchar2(255) );
Let’s have a look at a dummy rendering function and how you would use that new attribute.
function render_region ( p_plugin in apex_plugin.t_plugin, p_region in apex_plugin.t_region, p_is_printer_friendly in boolean ) return apex_plugin.t_region_render_result is l_result apex_plugin.t_region_render_result; begin -- Render plug-in ... -- Set the search field of the region plug-in as -- first navigable item l_result.navigable_dom_id := p_region.static_id || '_search_field'; return l_result; end render_region;
As you can see from the code I’m prefixing my search field with
p_region.static_id to get a unique field in case my region is used multiple times on a page. That’s it. If a developer sets Cursor Focus to First item on page and the region is the first component on the page, it will receive focus.
Interested in more Plug-in Enhancements?
Check out my other blog postings of this series of Plug-in Enhancements in Oracle APEX 5.0.