Element: <oj-c-radioset>

CORE PACK

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 16.0.0
Module:
  • radioset

Note: This component supersedes the following component: <oj-radioset>. Migration info available at preceding link.

QuickNav

Attributes


JET Radioset Component

Description: The oj-c-radioset component allows the user to select one option from a set of mutually exclusive options.

To use an oj-c-radioset, set the options attribute to an array of data items or to a DataProvider.

<oj-c-radioset
   value="current value"
   label-hint="Radioset"
   options="[[data]]"></oj-c-radioset>
It is recommended that the array option should only be used for static data and the DataProvider should always be used for mutable data.

You can enable and disable an oj-c-radioset, which will enable and disable all contained radio items.

You can also set an oj-c-radioset to readonly, which will make all the radio items readonly while making the selected radio option visually distinctive.

Validation and Messaging

An editable component runs validation (normal or deferred) based on the action performed on it (either by end-user or page author), and the state it was in when the action occurred. Examples of actions are - creating a component, user changing the value of the component by interacting with it, the app setting a value programmatically, the app calling the validate() method etc. At the time the action occurs, the component could already be showing errors, or can have a deferred error or have no errors.

These factors also determine whether validation errors/messages get shown to the user immediately or get deferred. The following sections highlight the kinds of validation that are run and how messages get handled.

Normal Validation

Normal validation is run in the following cases on the display value, using the converter and validators (this includes async-validators) set on the component, and validation errors are reported to user immediately.
  • When value changes as a result of user interaction all messages are cleared, including custom messages added by the app, and full validation is run on the UI value. The steps performed are outlined below.
    1. All messages are cleared and messagesCustom property is cleared
    2. If no converter is present then processing continues to next step. If a converter is present, the UI value is first converted (i.e., parsed). If there is a parse error then the messages are shown and processing returns.
    3. If there are no validators setup for the component then the value is set on the component. Otherwise all validators are run in sequence using the parsed value from the previous step. The implicit required is run first if the component is marked required. When a validation error is encountered it is remembered and the next validator in the sequence is run.
      • NOTE: The value is trimmed before required validation is run
    4. At the end of the validation run if there are errors, the messages are shown and processing returns. If there are async-validators, those errors are shown as soon as they come in, and not until all validators, sync and async validators, are complete, does processing return, that is, value and valid are updated. If there are no errors, then the value property is updated and the formatted value displayed on the UI.
  • When the validate method is called by app, all messages are cleared and full validation run using the display value. See validate method on the sub-classes for details. Note: JET validation is designed to catch user input errors, and not invalid data passed from the server; this should be caught on the server.
  • When certain properties change through programmatic intervention by app, the component determines whether it needs to run normal validation based on the state the component is in. Refer to the Mixed Validation section below for details.

Deferred Validation

Deferred validation is run in the following cases on the component value using the implicit required validator if required is true, and validation errors are deferred, i.e., not shown to user immediately. Refer to the Showing Deferred Messages section to understand how deferred messages can be shown.
  • When a component is created and it is required deferred validation is run and no messages are cleared prior to running validation. Refer to the Validators Participating in Deferred Validation section for details.
  • When the value property changes due to programmatic intervention deferred validation is run, after all messages and messagesCustom property are cleared.
  • When the reset method is called, deferred validation is run after all messages and messagesCustom property are cleared.
  • When certain properties change through programmatic intervention by app, the component determines whether it needs to run deferred validation based on the state the component is in. Refer to the Mixed Validation section below for details.

Mixed Validation

Either deferred or normal validation is run in the following cases based on the state the component is in and any validation errors encountered are either hidden or shown to user.
  • when disabled property changes. See disabled property for details.
  • when converter property changes. See converter property for details.
  • when required property changes. See required property for details.
  • when validators property changes. See validators property for details.

Showing Deferred Messages

Deferred validation messages are displayed only when page author requests for it explicitly in one of the following ways:

Validators Participating in Deferred Validation

The required validator is the only validator type that participates in deferred validation. The required property needs to be set to true for the required validator to run.

User Assistance Text

User assistive text provides guidance to help the user understand what data to enter or select.

By default all user assistance text shows inline at the top of the radioset and is always displayed if there is any defined for the set. See the user-assistance-density property for other ways the user assistance text can render. User assistance can also be provided at the individual radio item level which renders as a "?" icon and when clicked will display the assistive text in a pop-up.

The JET form component properties that are used for user assistance text are help.instruction, and help-hints. In the Redwood theme for clarity only one user assistance text shows to the user. The precedence rules are:

  • help.instruction shows;
  • if no help.instruction, then help-hints.definition shows;
  • help-hints.source always shows along side the above.

If the required property was set to true, this can also be used to guide the user. In this case, the word Required will be rendered under the radioset when no value was set for the component.

Touch End User Information

Target Gesture Action
Radio button Tap Select the radio button.
Radio button's label Tap Select the corresponding radio button.
Assistive help icon Tap If assistive text was setup for the radio button, pop up the notewindow.

Keyboard End User Information

Target Key Action
Input UpArrow Select the previous radio button in the group.
DownArrow Select the next radio button in the group.
Radioset Tab In If the radioset has help-hints.source, sets the focus on the link, otherwise sets the focus on the checked radio button. If no button was selected, sets the focus on the first radio button.
Assistive help icon Tab In If the radio item has assistive text, sets the focus on the icon. Hitting Enter or Space on the icon will launch a pop-up. Pressing F6 transfers the focus inside the popup and tabbing inside the popup will move focus to the link inside the popup, if one exists. Hitting Enter on the link will launch a new window with the url that was setup in the helpSourceLink property of the radio item. See RadiosetDataItem for information on assistive properties of the radio item.

Accessibility

JET oj-c-radioset takes care of setting role="radiogroup" on the oj-c-radioset element.

For accessibility, set the label-hint property. If the desire is to not have a visible label, then to make this accessible to screen reader users, set label-hint to a value and the label-edge to 'none' which renders an aria-label with the label-hint text.

Disabled content: JET supports an accessible luminosity contrast ratio, as specified in WCAG 2.0 - Section 1.4.3 "Contrast", in the themes that are accessible. (See the "Theming" chapter of the JET Developer Guide for more information on which themes are accessible.) Note that Section 1.4.3 says that text or images of text that are part of an inactive user interface component have no contrast requirement. Because disabled content may not meet the minimum contrast ratio required of enabled content, it cannot be used to convey meaningful information.


Usage

Signature:

interface CRadiosetElement<V extends string | number,D extends oj-c.Radioset.RadiosetDataItem>

Typescript Import Format
//To typecheck the element APIs, import as below.
import { CRadiosetElement } from "oj-c/radioset";

//For the transpiled javascript to load the element's module, import as below
import "oj-c/radioset";

For additional information visit:

Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.


Attributes

column-span :number

Specifies how many columns this component should span. This only takes effect when this component is a child of a form layout that has direction 'row'.
Default Value:
  • 1
Names
Item Name
Property columnSpan
Property change event columnSpanChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-column-span-changed

container-readonly :boolean

Specifies whether an ancestor container, like oj-c-form-layout, is readonly. This affects whether a readonly component renders in full or mixed readonly mode.
Names
Item Name
Property containerReadonly
Property change event containerReadonlyChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-container-readonly-changed

direction :"row"|"column"

Layout direction of the radioset radio elements.
Default Value:
  • "column"
Names
Item Name
Property direction
Property change event directionChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-direction-changed

disabled :boolean

Specifies whether the component is disabled or not. The default is false.

When the disabled property changes due to programmatic intervention, the component may clear messages and run validation in some cases.

  • when a required component is initialized as disabled value="{{currentValue}}" required disabled, deferred validation is skipped.
  • when a disabled component is enabled,
    • if the component is invalid and showing messages then all component messages are cleared, and full validation will be run using the display value.
      • if there are validation errors, they are shown.
      • if no errors result from the validation, the value property is updated. Page authors can listen to the valueChanged event to clear custom errors.
    • if the component is valid and has no errors then deferred validation is run.
      • if there is a deferred validation error, then the valid property is updated.
    • if the component is invalid and has deferred errors then component messages are cleared and deferred validation is re-run.
      • if there is a deferred validation error, then the valid property is updated.
  • when and enabled component is disabled then no validation is run and the component appears disabled.

Default Value:
  • false
Names
Item Name
Property disabled
Property change event disabledChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-disabled-changed

display-options :oj-c.Radioset.DisplayOptionsProps

Display options for auxiliary content that describes whether or not the auxiliary content should be displayed.
Names
Item Name
Property displayOptions
Property change event displayOptionsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-display-options-changed

help :oj-c.Radioset.Help

Form component help information.
Names
Item Name
Property help
Property change event helpChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-help-changed

help-hints :oj-c.Radioset.HelpHints

The helpHints object contains a definition property, sourceText property, and a source property.
Names
Item Name
Property helpHints
Property change event helpHintsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-help-hints-changed

label-edge :"inside"|"none"|"start"|"top"

Specifies how the label of the component is positioned when the label-hint attribute is set on the component.
Supported Values:
Value Description
inside The label will be placed on top of the radioset, but is smaller than the 'top' option.
none The radioset will not create a label, but instead will set the aria-label property on the radioset.
start The label will be placed before the start of the radioset.
top The label will be placed on top of the radioset.
Names
Item Name
Property labelEdge
Property change event labelEdgeChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-edge-changed

label-hint* :string

Represents a hint for rendering a label on the component. This is used in combination with the label-edge attribute to control how the label should be rendered.
Names
Item Name
Property labelHint
Property change event labelHintChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-hint*-changed

label-start-width :(number|string)

The width of the label when labelEdge is 'start'.

This attribute accepts values of type 0 | `var(${string})` | `--${string}` | `${number}%` | `${number}x` | `calc(${string})` | `${number}${CssUnits}

Names
Item Name
Property labelStartWidth
Property change event labelStartWidthChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-start-width-changed

label-wrapping :"truncate"|"wrap"

A property that applications can use to specify how the radioset label should render when there is not enough available space.
Supported Values:
Value Description
truncate Label will truncate if needed.
wrap Label will wrap if needed.
Names
Item Name
Property labelWrapping
Property change event labelWrappingChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-wrapping-changed

messages-custom :Array.<oj-c.Radioset.ComponentMessageItem>

List of messages an app would add to the component when it has business/custom validation errors that it wants the component to show. This allows the app to perform further validation before sending data to the server. When this option is set the message will be shown to the user right away. To clear the custom message, set messagesCustom back to an empty array.

See the Validation and Messages section for details on when the component clears messagesCustom; for example, when full validation is run.

Default Value:
  • []
Supports writeback:
  • true
Names
Item Name
Property messagesCustom
Property change event messagesCustomChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-messages-custom-changed

options* :(Array.<oj-c.Radioset.RadiosetArrayDataItem.<V>>|DataProvider.<V, D>)

The data provided to the radioset that represents one or more radio items. Regardless of the type used for this attribute (whether it's a DataProvider implementation or an Array of data items) the value and label properties are required. In the DataProvider case, the key of the DataProvider will be used as the radio item value. See the custom element usage section for details on the type parameter definitions.
Names
Item Name
Property options
Property change event optionsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-options*-changed

readonly :boolean

Whether the component is readonly. The readonly property sets or returns whether an element is readonly, or not. A readonly element cannot be modified. However, a user can tab to it, highlight it, focus on it, and copy the text from it. If you want to prevent the user from interacting with the element, use the disabled property instead.

If the property value is not set either directly on the component or inherited from a parent form layout, then the property is treated as if its value were false.

Names
Item Name
Property readonly
Property change event readonlyChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-readonly-changed

required :boolean

When this property is set to false it implies that a value is not required to be provided by the user. This is the default. When this property set to true implies that a value is required to be provided by the user.

In the Redwood theme, by default, a Required text is rendered inline when no radio option is selected.

The Required error text is based on Redwood UX designs, and it is not recommended to be changed. To override the required error message, use the required-message-detail attribute. The component's label text is passed in as a token {label} and can be used in the message detail.

When required is set to true, an implicit required validator is created, i.e., new RequiredValidator(). The required validator is the only validator to run during initial render, and its error is not shown to the user at this time; this is called deferred validation. The required validator also runs during normal validation; this is when the errors are shown to the user. See the Validation and Messaging section for details.

When the required property changes due to programmatic intervention, the component may clear component messages and run validation, based on the current state it's in.

Running Validation when required property changes

  • if component is valid when required is set to true, then it runs deferred validation on the value property. If the field is empty, the valid state is invalidHidden. No errors are shown to the user.
  • if component is valid when required is set from true to false, then no validation is run.
  • if component is invalid and has deferred messages (invalidHidden) when required is set to false, then component messages are cleared (messages-custom messages are not cleared) but no deferred validation is run because required is false.
  • if component is invalid and currently showing invalid messages (invalidShown) when required is changed to either true or false, then component messages are cleared and normal validation is run using the current display value.
    • if there are validation errors, then value property is not updated and the error is shown.
    • if no errors result from the validation, the value property is updated; page author can listen to the valueChanged event on the component to clear custom errors.

Clearing Messages when required property changes

  • Only messages created by the component, like validation messages, are cleared when the required property changes.
  • messagesCustom property is not cleared.

Default Value:
  • false
Names
Item Name
Property required
Property change event requiredChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-required-changed

required-message-detail :string

The component-specific message detail when the required validation fails. If the component needs a required validation error message that is different from the default, set this property. It should be a translated string.

Names
Item Name
Property requiredMessageDetail
Property change event requiredMessageDetailChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-required-message-detail-changed

user-assistance-density :"reflow"|"efficient"|"compact"

Specifies the density of the form component's user assistance presentation. It can be shown inline with reserved rows to prevent reflow if a user assistance text shows up, inline without reserved rows that would reflow if a user assistance text shows up, or it can be shown compactly in a popup instead.

If the property value is not set either directly on the component or inherited from a parent form layout, then the property is treated as if its value were "reflow".

Supported Values:
Value Description
compact Help and hints are shown above the field. Messages and required are shown inline under the field with reserved space.
efficient Help and hints are shown above the field. Messages and required are shown inline under the field with reserved space.
reflow Help and hints are shown above the field. Messages and required are shown inline under the field with no reserved space.
Names
Item Name
Property userAssistanceDensity
Property change event userAssistanceDensityChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-user-assistance-density-changed

(readonly) valid :"valid"|"pending"|"invalidHidden"|"invalidShown"

The current valid state of the component. It is evaluated on initial render. It is re-evaluated

  • when messagesCustom is updated, since messagesCustom can be added by the app developer any time.
  • when showMessages() is called. Since showMessages() moves the hidden messages into messages shown, if the valid state was "invalidHidden" then it would become "invalidShown".
  • when the required property has changed. If a component is empty and has required set, the valid state may be "invalidHidden" (if no invalid messages are being shown as well). If required property is removed, the valid state would change to "valid".

Note: New valid states may be added to the list of valid values in future releases. Any new values will start with "invalid" if it is an invalid state, "pending" if it is pending state, and "valid" if it is a valid state.

Supported Values:
Value Description
invalidHidden The component has invalid messages hidden and no invalid messages showing. An invalid message is one with severity 'error'.
invalidShown The component has invalid messages showing. An invalid message is one with severity 'error'.
pending The component is waiting for the validation state to be determined. The 'pending' state is set at the start of the convert/validate process.
valid The component is valid
Supports writeback:
  • true
Names
Item Name
Property valid
Property change event validChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-valid-changed

value :(V|null)

The value of the component.

When value property changes due to programmatic intervention, the component always clears all messages including messagesCustom, runs deferred validation, and always refreshes UI display value.

Running Validation

  • component always runs deferred validation; the valid property is updated with the result.
Default Value:
  • null
Supports writeback:
  • true
Names
Item Name
Property value
Property change event valueChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-value-changed

Methods

getProperty(property) : {any}

Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description
property The property name to get. Supports dot notation for subproperty access.
Returns:
Type
any

reset : {void}

Resets the component by clearing all messages.
Returns:
Type
void

setProperties(properties) : {void}

Performs a batch set of properties.
Parameters:
Name Type Description
properties An object containing the property and value pairs to set.
Returns:
Type
void

setProperty(property, value) : {void}

Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
Parameters:
Name Type Description
property The property name to set. Supports dot notation for subproperty access.
value The new value to set the property to.
Returns:
Type
void

showMessages : {void}

Takes all deferred messages and shows them. It then updates the valid property; e.g., if the valid state was "invalidHidden" before showMessages(), the valid state will become "invalidShown" after showMessages().

If there were no deferred messages this method simply returns.
Returns:
Type
void

validate : {Promise}

Validates the component's display value using all validators registered on the component and updates the value option by performing the following steps.
  1. All messages are cleared, including custom messages added by the app.
  2. The implicit required validator is run if the component is marked required.
  3. At the end of validation if there are errors, the messages are shown. If there were no errors, then the value property is updated.
Returns:

Promise resolves to "valid" if the component passed all validations, or "invalid" if there were validation errors.

Type
Promise

Type Definitions

ComponentMessageItem

A type for a single component message
Properties:
Name Type Argument
detail string <optional>
severity "error" | "confirmation" | "info" | "warning" <optional>
summary string <optional>

DisplayOptionsProps

Display options for auxiliary content that determines whether or not it should be displayed.
Properties:
Name Type Argument Default Description
messages "none" | "display" <optional>
"display" Display options for auxiliary message text.

Help

Form component help information.
Properties:
Name Type Argument Description
instruction string <optional>
A type of user assistance text. User assistance text is used to provide guidance to help the user understand what data to enter or select.

HelpHints

The helpHints object contains a definition property and a source property.
Properties:
Name Type Argument Description
definition string <optional>
A type of user assistance text. User assistance text is used to provide guidance to help the user understand what data to enter or select. help-hints could come from a help system.
source string <optional>
Help source URL associated with the component.
sourceText string <optional>
Custom text to be used for the source link.

RadiosetArrayDataItem<V extends string | number>

An object that represents the value and corresponding data associated with a radio item in a rendered radioset. The label property is required and provides the text for the radio element.
Properties:
Name Type Argument Description
assistiveText string <optional>
Optional value to provide guidance to the user about the radio item this applies to.
helpSourceLink string <optional>
Optional link to aid the user in the radio item this applies to.
helpSourceText string <optional>
Optional custom text to be rendered for the helpSourceLink.
label string The value of this required property will provide the text for the radio button's label.
value V

RadiosetDataItem

An object that represents the data associated with a radio item in a rendered radioset. The label property is required and provides the text for the radio item.
Properties:
Name Type Argument Description
assistiveText string <optional>
Optional value to provide guidance to the user about the radio item this applies to.
helpSourceLink string <optional>
Optional link to aid the user in the radio item this applies to.
helpSourceText string <optional>
Optional custom text to be rendered for the helpSourceLink.
label string The value of this required property will provide the text for the radio button's label.