27.17 GET_ELEMENT_ATTRIBUTES Function

This function returns some of the standard attributes of an HTML element (for example, id, name, required, placeholder, aria-error-attributes, class) which is used if a HTML input/select/textarea/... tag is generated to get a consistent set of attributes.

Syntax

APEX_PLUGIN_UTIL.GET_ELEMENT_ATTRIBUTES (
    p_item in apex_plugin.t_page_item,
    p_name in varchar2 default null,
    p_default_class in varchar2 default null,
    p_add_id in boolean default true,
    p_add_labelledby in boolean default true 
    p_aria_describedby_id in varchar2 default null ) 
    return varchar2;

Parameters

Table 27-22 GET_ELEMENT_ATTRIBUTES Function Parameters

Parameters Description

p_item

This is the p_item parameter of your plug-in function.

p_name

This is the value which has been return by apex_plugin.get_input_name_or_page_item

p_default_class

Default CSS class which which should be contained in the result string.

p_add_id

If set to TRUE then the id attribute is also contained in the result string.

p_add_labelled_by

Returns some of the general attributes of an HTML element (for example, the ID, name, required, placeholder, aria-error-attributes, class) which should be used if an HTML input, select, or textarea tag is generated to get a consistent set of attributes.Set to FALSE if you render a HTML input element like input, select, or textarea which does not require specifying the aria-labelledby attribute because the label's for attribute works for those HTML input elements. Set it to TRUE for all 'non-standard form element widgets (that is, those using div, span, and so on.) which do allow focus to make them accessible to screen readers.

Note: Inclusion of aria-labelled by is also dependent on the item plug-in having Standard Form Element set to No and that there is a #LABEL_ID# substitution defined in the item's corresponding label template.

p_aria_describedby_id

Pass additional IDs here that you would like get_element_attributes to include in the value it renders for the 'aria-describedby' attribute on the form element. This can be useful if you would like to convey additional information to users of Assistive Technology, when they are focused on the form field.

Example

This example emits an INPUT tag of type text which uses apex_plugin_util.get_element_attributes to automatically include the most common attributes.

sys.htp.prn (
        '<input type="text" ' ||
        apex_plugin_util.get_element_attributes(p_item, l_name, 'text_field') ||
        'value="'||l_escaped_value||'" '||
        'size="'||p_item.element_width||'" '||
        'maxlength="'||p_item.element_max_length||'" '||
        ' />');