Element: <oj-buttonset-many>

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

Signature:

class ojButtonsetMany

QuickNav

Attributes

JET Custom Elements

JET components are implemented as custom HTML elements. In addition to the component attributes documented in this page, JET components also support standard HTML global attributes like id and aria-label.

The JET data binding syntax can be used to define both component and global attributes through the use of dynamically evaluated expressions. All attributes (component and global) support attribute-level binding by prefixing the attribute name with ":" (e.g. :id="[...]"). When using attribute-level binding, all expression values are treated as strings. Additionally, component attributes support property-level binding by using the attribute name directly with no ":" prefix. When using property-level binding, the expressions should evaluate to the types documented by the corresponding attributes. Property-level binding is strongly recommended over attribute-level binding for component attributes.

A detailed description of working with custom HTML elements can be found in: JET Custom Element Usage.



PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

Version:
  • 7.1.0
Since:
  • 0.6.0
Module:
  • ojbutton

Module usage

See JET Module Loading for an overview of module usage within JET.

Typescript Import Format
//To typecheck the element APIs, import as below.
import {ojButtonsetMany} from "ojs/ojbutton";

//For the transpiled javascript to load the element's module, import as below
import "ojs/ojbutton";

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.


JET Buttonset Many

Description: Themeable, WAI-ARIA-compliant visual and semantic grouping container for JET Buttons.

The JET ButtonsetMany can be used to group related buttons, where any number of the buttons can be selected. Buttonset provides visual and semantic grouping and WAI-ARIA-compliant focus management.

When a Buttonset is created or refreshed, it creates JET Buttons out of all contained oj-option DOM elements by wrapping them and calling .ojButton() on the generated content. The Buttonset will remove all non oj-option DOM elements from the Buttonset.

oj-options in the buttonset should specify the oj-option value attribute, since the oj-buttonset-mnay value attribute refers to that attribute.

<oj-buttonset-many id="myButtonset">
  <oj-option value="myValue0">Value0</oj-option>
  <oj-option value="myValue1">Value1</oj-option>
</oj-buttonset-many>

Touch End User Information

All Buttonset touch interaction is with the individual buttons. See the JET Button touch gesture doc.

Keyboard End User Information

JET Buttonset is a single tabstop, with arrow-key navigation within the buttonset, as follows:

Key Action
LeftArrow Navigate to the previous enabled button on the left, wrapping around at the end.
RightArrow Navigate to the next enabled button on the right, wrapping around at the end.

See also the JET Button keyboard doc, for details on interacting with the individual buttons.

Keyboard Application Developer Information

The application should not do anything to interfere with the Buttonset's focus management, such as setting the tabindex of the buttons. Also, enabled buttons should remain user-visible, without which arrow-key navigation to the button would cause the focus to seemingly disappear.

The buttonset's focus management should be turned off when placing the buttonset in a JET Toolbar. See the focusManagement attribute. In this case, the "Keyboard End User Information" documented above is superseded by the Toolbar's documented keyboard behavior.

Accessibility

The application is responsible for applying aria-label and/or aria-controls attributes like the following to the buttonset element, if applicable per the instructions that follow:

aria-label="Choose only one beverage."
aria-controls="myTextEditor"

An aria-label conveying the "choose only one" semantics should be included for a buttonset-one.

The aria-controls attribute should be included if the buttonset is controlling something else on the page, e.g. bold / italic / underline buttons controlling a rich text editor. If the buttonset is contained in a toolbar, aria-controls should be placed on the toolbar, not on the buttonsets within the toolbar.

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.

Styling

The following CSS classes can be applied by the page author as needed.

Class Description
oj-buttonset-width-auto Forces Buttonset Buttons' widths to be determined by the total width of their icons and label contents, overriding any theming defaults.

Optionally, specify the overall width of the Buttonset for further width control.

Can be applied to Buttonset's root element, or on an ancestor such as Toolbar or document.

oj-buttonset-width-equal Forces Buttonset Buttons' widths to be equal, overriding any theming defaults.

Note that the overall width of the Buttonset defaults to 100%; set the max-width (recommended) or width of the Buttonset for further width control.

Can be applied to Buttonset's root element, or on an ancestor such as Toolbar or document.

Reading direction

The only supported way to set the reading direction (LTR or RTL) is to set the "dir" attribute on the <html> element of the page. As with any JET component, in the unusual case that the reading direction is changed post-create, the buttonset must be refresh()ed, or the page must be reloaded.

Declarative Binding

For components like Buttonset and Menu that contain a number of like items, applications may wish to use an oj-bind-for-each to stamp out the contents as follows:

<oj-buttonset-many id="drinkset">
      <oj-bind-for-each data="[[drinkValues]]">
        <template>
          <oj-option value="[[$current.data.id]]">
            <span>
              <oj-bind-text value="[[$current.data.label]]"></oj-bind-text>
            </span>
          </oj-option>
        </template>
      </oj-bind-for-each>
  </oj-buttonset-many>

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.

Slots

JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.

Default

The <oj-buttonset-many> element accepts oj-option elements as children. See the oj-option documentation for details about accepted children and slots.

contextMenu

The contextMenu slot is set on the oj-menu within this element. This is used to designate the JET Menu that this component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the JET Menu specified in this slot.

The application can register a listener for the Menu's ojBeforeOpen event. The listener can cancel the launch via event.preventDefault(), or it can customize the menu contents by editing the menu DOM directly, and then calling refresh() on the Menu.

To help determine whether it's appropriate to cancel the launch or customize the menu, the ojBeforeOpen listener can use component API's to determine which table cell, chart item, etc., is the target of the context menu. See the JSDoc of the individual components for details.

Keep in mind that any such logic must work whether the context menu was launched via right-click, Shift-F10, Press & Hold, or component-specific touch gesture.

Attributes

chroming :"full"|"half"|"outlined"

Indicates in what states the buttonset's buttons have chrome (background and border).

A buttonset's chroming must be set by setting this buttonset attribute (or setting the chroming attribute of a containing toolbar).

The default chroming varies by theme and containership as follows:

  • If the buttonset is in a toolbar, then the default chroming is the current value of the toolbar's chroming attribute.
  • Else, if $buttonsetChromingOptionDefault is set in the current theme as seen in the example below, then that value is the chroming default.
  • Else, the default chroming is "full".

Once a value has been set on this buttonset attribute, that value applies regardless of theme and containership.

Supported Values:
Value Description
"full" In typical themes, full-chrome buttons always have chrome.
"half" In typical themes, half-chrome buttons acquire chrome only in their hover, active, and selected states. A buttonset with half-chroming will be styled to have normal button spacing. Half-chroming is recommended for buttons in a toolbar. (This is the toolbar default in most themes.)
"outlined" In typical themes, outlined buttons are similar to half-chrome buttons, but have a border in the default state.
Names
Item Name
Property chroming
Property change event chromingChanged
Property change listener attribute (must be of type function) on-chroming-changed

(nullable) described-by :string

It is used to establish a relationship between this component and another element. Typically this is not used by the application developer, but by the oj-label custom element's code. One use case is where the oj-label custom element code writes described-by on its form component for accessibility reasons. To facilitate correct screen reader behavior, the described-by attribute is copied to the aria-describedby attribute on the component's dom element.
Names
Item Name
Property describedBy
Property change event describedByChanged
Property change listener attribute (must be of type function) on-described-by-changed

disabled :boolean

Setting the Buttonset's disabled attribute effectively disables all its Buttons, without affecting their disabled attributes. Thus, a Button is effectively disabled if either its own disabled attribute is set, or the Buttonset's disabled attribute is set.

Default Value:
  • false
Names
Item Name
Property disabled
Property change event disabledChanged
Property change listener attribute (must be of type function) on-disabled-changed

display :"all"|"icons"

Whether to display both the label and icons ("all") or just the icons ("icons") of the buttons. In the latter case, the label is displayed in a tooltip instead.

The display attribute will be ignored if no icons exist in the button.

Supported Values:
Value Description
"all" Display both the label and icons.
"icons" Display only the icons.
Default Value:
  • "all"
Names
Item Name
Property display
Property change event displayChanged
Property change listener attribute (must be of type function) on-display-changed

focus-management :"oneTabstop"|"none"

The focusManagement attribute should be set to "none" when the Buttonset is placed in a JET Toolbar. This allows the Toolbar to manage the focus with no interference from the Buttonset, so that arrow keys move within the entire Toolbar, not just within the Buttonset.
Supported Values:
Value Description
"none" Focus management is disabled, to avoid interfering with the focus management of a containing component.
"oneTabstop" Focus management is enabled. The Buttonset is a single tabstop with arrow-key navigation.
Default Value:
  • "oneTabstop"
Names
Item Name
Property focusManagement
Property change event focusManagementChanged
Property change listener attribute (must be of type function) on-focus-management-changed

labelled-by :string|null

It is used to establish a relationship between this component and another element. A common use is to tie the oj-label and the oj-buttonset together for accessibility. The oj-label custom element has an id, and you use the labelled-by attribute to tie the two components together to facilitate correct screen reader behavior.
Names
Item Name
Property labelledBy
Property change event labelledByChanged
Property change listener attribute (must be of type function) on-labelled-by-changed

translations :object|null

A collection of translated resources from the translation bundle, or null if this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.

If the component does not contain any translatable resource, the default value of this attribute will be null. If not, an object containing all resources relevant to the component.

If this component has translations, their documentation immediately follows this doc entry.

Names
Item Name
Property translations
Property change event translationsChanged
Property change listener attribute (must be of type function) on-translations-changed

value :Array.<any>|null

The value attribute indicates which oj-options in the Buttonset are selected. It corresponds to the value attribute of those elements, which should always be set. value is a possibly empty, non-null string array containing the value attributes of the selected oj-options. This array has "set", not "list", semantics; i.e. order is neither important nor guaranteed. Thus, an n-oj-option set has 2^n valid value values: the 2^n possible subsets of n oj-options.

In all other cases, value is null.

It's still possible for the value attribute and DOM to get out of sync by other means. In this case, the app is responsible for updating the value attribute. A typical case is when the set of Buttons contained in the Buttonset changes, possibly due to a Knockout binding, in which case the app must first call refresh (as in all cases when the DOM changes underneath a component), and then update the value attribute to the desired value.

Often there is no need to listen for this event, since the value binding, discussed above, will update the bound observable whenever the value state changes. The declarative binding is often preferable to an explicit listener.

A click listener should not be used to detect changes to the value state. The attribute value binding and/or the valueChange event should be used instead.

Default Value:
  • null
Supports writeback:
  • true
Names
Item Name
Property value
Property change event valueChanged
Property change listener attribute (must be of type function) on-value-changed

Methods

getProperty(property) → {any}

Retrieves the value of a property or a subproperty. The return type will be the same as the type of the property as specified in this API document. If the method is invoked with an incorrect property/subproperty name, it returns undefined.
Parameters:
Name Type Description
property string The property name to get. Supports dot notation for subproperty access.
Since:
  • 4.0.0
Returns:
Type
any
Example

Get a single subproperty of a complex property:

let subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2');

refresh() → {void}

Refreshes the component.
Returns:
Type
void

setProperties(properties) → {void}

Performs a batch set of properties. The type of value for each property being set must match the type of the property as specified in this API document.
Parameters:
Name Type Description
properties Object An object containing the property and value pairs to set.
Since:
  • 4.0.0
Returns:
Type
void
Example

Set a batch of properties:

myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"});

setProperty(property, value) → {void}

Sets a property or a subproperty (of a complex property) and notifies the component of the change, triggering a [property]Changed event. The value should be of the same type as the type of the attribute mentioned in this API document.
Parameters:
Name Type Description
property string The property name to set. Supports dot notation for subproperty access.
value any The new value to set the property to.
Since:
  • 4.0.0
Returns:
Type
void
Example

Set a single subproperty of a complex property:

myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");