Element: <oj-select-many>

Oracle® JavaScript Extension Toolkit (JET)
4.2.0

E91398-01

QuickNav

Attributes

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

Version:
  • 4.2.0
Since:
  • 0.6

JET Custom Elements

JET components are implemented as custom HTML elements. A detailed description of working with these elements can be found in: JET Custom Element Usage.

JET Select Many

Description: JET Select Many provides support for multi-select and search filtering.

A JET Select Many can be created with the following markup.


<oj-select-many>
  <oj-option value="option 1">option 1</oj-option>
  <oj-option value="option 2">option 2</oj-option>
  <oj-option value="option 3">option 3</oj-option>
  <oj-option value="option 4">option 4</oj-option>
</oj-select-many> 

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 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 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 refresh method is called. See refresh method for details.
  • when converter property changes. Not all EditableValue components have the converter property. See the sub-classes that have the converter property for details, e.g., oj.inputBase#converter.
  • when required property changes. Not all EditableValue components have the required property. See the sub-classes that have the required property for details, e.g., oj.inputBase#required.
  • when validators property changes. Not all EditableValue components have the validators property. See the sub-classes that have the validators property for details, e.g., oj.inputBase#validators.

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.

Touch End User Information

Target Gesture Action
Select box Tap If the drop down is not open, expand the drop down list. Otherwise, close the drop down list. If hints, title or messages exist in a notewindow, pop up the notewindow.
Option item Tap Tap on a option item in the drop down list to add to selection.
Selected Item with Clear Entry Button Tap Remove item from the selected items list by taping on the clear button next to the data item.
Drop down swipe up/down Scroll the drop down list vertically

Keyboard End User Information

Target Key Action
Option item Enter Select the highlighted choice from the drop down list.
Drop down UpArrow or DownArrow Highlight the option item in the direction of the arrow. If the drop down is not open, expand the drop down list.
Select box LeftArrow or RightArrow Move focus to the previous or next selected item.
Drop down Esc Collapse the drop down list. If the drop down is already closed, do nothing.
Select box or search box any characters for the search term filter down the results with the search term.
Select Tab In Set focus to the select. If hints, title or messages exist in a notewindow, pop up the notewindow.

Disabled option items receive no highlight and are not selectable.

Reading direction

As with any JET element, in the unusual case that the directionality (LTR or RTL) changes post-init, the Select must be refresh()ed.

Accessibility

It is up to the application developer to associate an oj-label to the select element. You should put an id on the select element, and then set the for attribute on the oj-label to be the select's id.

The element will decorate its associated label with required and help information, if the required and help attributes are set.

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 elements can have up to two types of child content:

Default

The <oj-select-many> element accepts oj-options as children. See the oj-option doc for details about accepted children and slots.

Example

Initialize the select with child content specified:

<oj-select-many>
  <oj-option value="option1">Option1</oj-option>
</oj-select-many>

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 and demos 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.

Example

Initialize the component with a context menu:

<oj-some-element>
    <-- use the contextMenu slot to designate this as the context menu for this component -->
    <oj-menu slot="contextMenu" style="display:none" aria-label="Some element's context menu">
...
    </oj-menu>
</oj-some-element>

Attributes

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.
Since:
  • 4.0.0
Names
Item Name
Property describedBy
Property change event describedByChanged
Property change listener attribute (must be of type function) on-described-by-changed
Examples

Initialize component with the described-by attribute specified:

<oj-some-element described-by="someId"></oj-some-element>

Get or set the describedBy property after initialization:

// getter
var descById = myComp.describedBy;

// setter
myComp.describedBy = "someId";

disabled :boolean

Whether the component is disabled. 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 component is invalid and showing messages then all component messages are cleared, and full validation 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 onValueChanged event to clear custom errors.
    • if 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 component is invalid and deferred errors then component messages are cleared and deferred validation re-run.
      • if there is a deferred validation error, then the valid property is updated.
  • when enabled component is disabled then no validation is run and the component appears disabled.

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

Initialize component with disabled attribute:

<oj-some-element disabled></oj-some-element>

Get or set the disabled property after initialization:

// getter
var disabled = myComp.disabled;

// setter
myComp.disabled = false;

display-options :Object|undefined

Display options for auxilliary content that determines where it should be displayed in relation to the component.

The types of messaging content for which display options can be configured include messages, converterHint, validatorHint and helpInstruction.
The display options for each type is specified either as an array of strings or a string. When an array is specified the first display option takes precedence over the second and so on.

JET editable components set defaults that apply to the entire app/page. It is possible to override the defaults on a per instance basis as explained in the examples below or change defaults for the entire application using oj.Components#setDefaultOptions method. It is much easier to change the defaults using setDefaultOptions once rather than putting the displayOptions option on every component instance.

When display-options changes due to programmatic intervention, the component updates its display to reflect the updated choices. For example, if 'help.instruction' property goes from 'notewindow' to 'none' then it no longer shows in the notewindow.

A side note: help.instruction and message detail text can include formatted HTML text, whereas hints and message summary text cannot. If you use formatted text, it should be accessible and make sense to the user if formatting wasn't there. To format the help.instruction, you could do this:

<html>Enter <b>at least</b> 6 characters</html>

Properties:
Name Type Argument Description
converterHint Array | string <optional>
supported values are 'placeholder', 'notewindow', 'none'. The default value is ['placeholder', 'notewindow']. When there is already a placeholder set on the component, the converter hint falls back to display type of 'notewindow'. To change the default value you can do this -
E.g. {'displayOptions: {'converterHint': ['none']}}
validatorHint Array | string <optional>
supported values are 'notewindow', 'none'. To change the default value you can do this -
{'displayOptions: {'validatorHint': ['none']}}
messages Array | string <optional>
supported values are 'notewindow', 'inline', 'none'. The default is 'inline'. To change the default value you can do this -
E.g. {'displayOptions: {'messages': 'none'}}
helpInstruction Array | string <optional>
supported values are 'notewindow', 'none'. To change the default value you can do this -
E.g. displayOptions='{"helpInstruction": "none"}'
Default Value:
  • {'messages': ['inline'],'converterHint': ['placeholder','notewindow'],'validatorHint': ['notewindow'],'helpInstruction': ['notewindow']}
Since:
  • 0.7
Names
Item Name
Property displayOptions
Property change event displayOptionsChanged
Property change listener attribute (must be of type function) on-display-options-changed
Examples

Override default values for displayOptions for messages for the entire application:

// messages will be shown in the notewindow for the application.
oj.Components.setDefaultOptions({
   'editableValue':
   {
     'displayOptions': 
     {
       'messages': ['notewindow']
     }
   }
});

Override default values for display-options for one component:

// In this example, the display-options are changed from the defaults.
// The 'converterHint' is none, the 'validatorHint' is none and the 'helpInstruction' is none,
// so only the 'messages' will display in its default state.
// For most apps, you will want to change the displayOptions app-wide
// for all EditableValue components, so you should use the
// oj.Components#setDefaultOptions function instead (see previous example).
//
<oj-some-element display-options='{"converterHint": "none",
                                    "validatorHint": "none",
                                    "helpInstruction": "none"}'></oj-some-element>

Get or set the displayOptions property after initialization:

// Get one subproperty
var hint = myComp.displayOptions.converterHint;

// Set one, leaving the others intact. Use the setProperty API for 
// subproperties so that a property change event is fired.
myComp.setProperty("displayOptions.converterHint", "none");

// get all
var options = myComp.displayOptions;

// set all.  Must list every resource key, as those not listed are lost.
myComp.displayOptions = {converterHint: "none", validatorHint: "none", helpInstruction: "none"};

help :Object.<string, string>

Form component help information.

The properties supported on the help option are:

Properties:
Name Type Argument Description
instruction string <optional>
this represents advisory information for the component The default value is null.
Default Value:
  • {'help' : {'instruction': null}}
Since:
  • 0.7
Names
Item Name
Property help
Property change event helpChanged
Property change listener attribute (must be of type function) on-help-changed

help.instruction :string|undefined

Represents advisory information for the component, such as would be appropriate for a tooltip.

When help.instruction is present it is by default displayed in the notewindow, or as determined by the 'helpInstruction' property set on the displayOptions attribute. When the help.instruction property changes the component refreshes to display the updated information.

JET takes the help instruction text and creates a notewindow with the text. The help instruction only shows up as a tooltip on mouse over, not on keyboard and not in a mobile device. So help instruction would only be for text that is not important enough to show all users, or for text that you show the users in another way as well, like in the label. Also you cannot theme the native browser's title window like you can the JET notewindow, so low vision users may have a hard time seeing it. For these reasons, the JET EditableValue components do not use the HTML's title attribute.

To include formatted text in the help.instruction, format the string using html tags. For example the help.instruction might look like:

<oj-some-element help.intruction="<html>Enter <b>at least</b> 6 characters</html>"></oj-some-element>
If you use formatted text, it should be accessible and make sense to the user if formatting wasn't there.

Default Value:
  • null
Since:
  • 4.0.0
Names
Item Name
Property help.instruction
Examples

Initialize the component with the help.instruction sub-attribute:

<oj-some-element help.instruction="some tooltip"></oj-some-element>
 

Get or set the help.instruction property after initialization:

// Get one subproperty
var instr = myComp.help.instruction;

// Set one subproperty, leaving the others intact. Use the setProperty API for 
// subproperties so that a property change event is fired.
myComponent.setProperty('help.instruction', 'some new value');

// Get all
var values = myComponent.help;

// Set all.  Must list every resource key, as those not listed are lost.
myComponent.help = {
  instruction: 'some new value'
};

help-hints :Object.<string, string>

Represents hints for oj-form-layout element to render help information on the label of the editable component.

This is used only if the editable component is added as a direct child to an oj-form-layout element, and the labelHint property is also specified.

The helpHints object contains a definition property and a source property.

  • definition - hint for help definition text.
  • source - hint for help source URL.
Default Value:
  • {'definition': "", 'source': ""}
Since:
  • 4.1.0
Names
Item Name
Property helpHints
Property change event helpHintsChanged
Property change listener attribute (must be of type function) on-help-hints-changed
Examples

Initialize the component with help hints:

<!-- Using dot notation -->
<oj-some-element help-hints.definition='some value' help-hints.source='some-url'></oj-some-element>

<!-- Using JSON notation -->
<oj-some-element help-hints='{"definition":"some value", "source":"some-url"}'></oj-some-element>

Get or set the helpHints property after initialization:

// Get one
var value = myComponent.helpHints.definition;

// Set one, leaving the others intact. Always use the setProperty API for 
// subproperties rather than setting a subproperty directly.
myComponent.setProperty('helpHints.definition', 'some new value');

// Get all
var values = myComponent.helpHints;

// Set all.  Must list every subproperty, as those not listed are lost.
myComponent.helpHints = {
    definition: 'some new value',
    source: 'some-new-url'
};

help-hints.definition :string

Hint for help definition text associated with the label.

It is what shows up when the user hovers over the help icon, or tabs into the help icon, or press and holds the help icon on a mobile device. No formatted text is available for help definition attribute.

See the help-hints attribute for usage examples.

Default Value:
  • ""
Since:
  • 4.1.0
Names
Item Name
Property helpHints.definition

help-hints.source :string

Hint for help source URL associated with the label.

If present, a help icon will render next to the label. For security reasons we only support urls with protocol http: or https:. If the url doesn't comply we ignore it and throw an error. Pass in an encoded URL since we do not encode the URL.

See the help-hints attribute for usage examples.

Default Value:
  • ""
Since:
  • 4.1.0
Names
Item Name
Property helpHints.source

label-hint :string

Represents a hint for oj-form-layout element to render a label on the editable component.

This is used only if the editable component is added as a direct child to an oj-form-layout element.

When labelHint is present it gives a hint to the oj-form-layout element to create an oj-label element for the editable component. When the labelHint property changes oj-form-layout element refreshes to display the updated label information.

Default Value:
  • ""
Since:
  • 4.1.0
Names
Item Name
Property labelHint
Property change event labelHintChanged
Property change listener attribute (must be of type function) on-label-hint-changed
Examples

Initialize the component with the label-hint attribute specified:

<oj-some-element label-hint='input label'></oj-some-element>

Get or set the labelHint property after initialization:

// getter
var value = myComponent.labelHint;

// setter
myComponent.labelHint = 'some new value'

messages-custom :Array.<Object>|undefined

List of messages an app would add to the component when it has business/custom validation errors that it wants the component to show. When this option is set the message shows to the user right away. To clear the custom message, set messagesCustom back to an empty array.

Each message in the array is an object that duck types oj.Message. See oj.Message for details.

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
Since:
  • 0.7
Names
Item Name
Property messagesCustom
Property change event messagesCustomChanged
Property change listener attribute (must be of type function) on-messages-custom-changed
Examples

Initialize component with the messages-custom attribute specified:

<oj-some-element messages-custom='[{"summary":"hello","detail":"detail"}]'></oj-some-element>

Get or set the messagesCustom property after initialization:

// getter
var customMsgs = myComp.messagesCustom;

// setter
myComp.messagesCustom = [{summary:"hello", detail:"detail", severity:oj.Message.SEVERITY_LEVEL.INFO}];

Set messagesCustom when there are cross-validation errors:

--- HTML ---
<oj-some-element messages-custom='{{messagesCustom}}'></oj-some-element> 

--- ViewModel code ---
self.messagesCustom = ko.observableArray([]);

// the app's function that gets called when the user presses the submit button
if (!myValidateCrossValidationFields())
{
  // the app adds a custom messages to the component and it is displayed right away
  var msgs = [];
  msgs.push({'summary':'Cross field error', 'detail':'Field 1 needs to be less than Field 2'});
  self.messagesCustom(msgs);
}
else
{
  // submit data to the server
}

minimum-results-for-search :number

The threshold for showing the search box in the dropdown when it's expanded. The search box is always displayed when the results size is greater than the threshold, otherwise the search box is initially turned off. However, the search box is displayed as soon as the user starts typing.
Default Value:
  • 15
Names
Item Name
Property minimumResultsForSearch
Property change event minimumResultsForSearchChanged
Property change listener attribute (must be of type function) on-minimum-results-for-search-changed
Example

Get or set the minimumResultsForSearch property after initialization:

// getter
var minimumResultsForSearch = mySelect.minimumResultsForSearch;

// setter
mySelect.minimumResultsForSearch = 10;

option-renderer :function(Object)|null

The renderer function that renders the content of each option. The function should return one of the following:
  • An Object with the following property:
    • insert: HTMLElement - A DOM element representing the content of the option.
  • undefined: If the developer chooses to manipulate the option content directly, the function should return undefined.

The option-renderer decides only how the options' content has to be rendered in the drop down. Once an option is selected from the drop down, what value has to be displayed in the in input field is decided by the label field in the data object. See options and options-keys for configuring option label and value.

The context parameter passed to the renderer contains the following keys:

Key Description
component A reference to the Select element.
parent The parent of the data item. The parent is null for root node.
index The index of the option, where 0 is the index of the first option. In the hierarchical case the index is relative to its parent.
depth The depth of the option. The depth of the first level children under the invisible root is 0.
leaf Whether the option is a leaf or a group.
data The data object for the option.
parentElement The option label element. The renderer can use this to directly append content.
Default Value:
  • null
Names
Item Name
Property optionRenderer
Property change event optionRendererChanged
Property change listener attribute (must be of type function) on-option-renderer-changed
Examples

Initialize the Select with a renderer:

<oj-select-many option-renderer="[[optionRenderer]]"></oj-select-many>
 var optionRenderer = function(optionContext) {
           return optionContext['data']['FIRST_NAME'];
         };

options :Array.<oj.Option|oj.Optgroup>

The option items for the Select. This attribute can be used instead of providing a list of oj-option or oj-optgroup child elements of the Select element. This attribute accepts:
  1. an array of oj.Options and/or oj.Optgroups.
    • Use oj.Option for a leaf option.
    • Use oj.Optgroup for a group option.
  2. a data provider of oj.Options. This data provider must implement oj.IteratingDataProvider.
    • value in oj.Option must be the row key in the data provider.
    • A maximum of 15 rows will be displayed in the dropdown. If more than 15 results are available then users need to filter further. Please note that users can't filter further if render-mode is native.
    • If it doesn't implement oj.FetchByKeys, JET Select will do brute force fetching.
Default Value:
  • null
Names
Item Name
Property options
Property change event optionsChanged
Property change listener attribute (must be of type function) on-options-changed
Examples

Initialize the Select with the options attribute specified:

<oj-select-many options="[[dataArray]]"></oj-select-many>

The options array should contain objects with value and label properties:

var dataArray = [{value: 'option1', label: 'Option 1'}, 
                 {value: 'option2', label: 'Option 2', disabled: true}, 
                 {value: 'option3', label: 'Option 3'}];

Initialize the Select with a data provider and data mapping:

<oj-select-many options="[[dataProvider]]"></oj-select-many>

Data mapping can be used if data doesn't have value and label properties.

// actual field names are "id" and "name"
var dataArray = [
           {id: 'Id 1', name: 'Name 1'},
           {id: 'Id 2', name: 'Name 2'},
           {id: 'Id 3', name: 'Name 3'}];

// In mapfields, map "name" to "label" and "id" to "value"
var mapFields = function(item) {
  var data = item['data'];
  var mappedItem = {};
  mappedItem['data'] = {};
  mappedItem['data']['label'] = data['name'];
  mappedItem['data']['value'] = data['id'];
  mappedItem['metadata'] = {'key': data['id']};
  return mappedItem;
}; 
var dataMapping = {'mapFields': mapFields};

var arrayDataProvider = new oj.ArrayDataProvider(dataArray, {idAttribute: 'id'});
var dataProvider = new oj.ListDataProviderView(arrayDataProvider, {'dataMapping': dataMapping});

options-keys :Object

Specify the key names to use in the options array.

Depending on options-keys means that the signature of the data does not match what is supported by the options attribute. When using Typescript, this would result in a compilation error.

Best practice is to use a oj.ListDataProviderView with data mapping as a replacement.

However, for the app that must fetch data from a REST endpoint where the data fields do not match those that are supported by the options attribute or the dataProvider doesn't implement oj.FetchByKeys, you may use the options-keys with any dataProvider that implements only oj.IteratingDataProvider interface.

Default Value:
  • null
Names
Item Name
Property optionsKeys
Property change event optionsKeysChanged
Property change listener attribute (must be of type function) on-options-keys-changed
Examples

Initialize the Select with options-keys specified. This allows the key names to be redefined in the options array.

<oj-select-xxx options-keys="[[optionsKeys]]"></oj-select-xxx>
 var optionsKeys = {value : "state_abbr", label : "state_name"};

Redefine keys for data with subgroups.

var optionsKeys = {label : "regions", children : "states", 
                   childKeys : {value : "state_abbr", label : "state_name"}};

options-keys.child-keys :Object

The object for the child keys.
Properties:
Name Type Argument Description
label string <nullable>
The key name for the label.
value string <nullable>
The key name for the value.
children string <nullable>
The key name for the children.
childKeys Object <nullable>
The object for the child keys.
Default Value:
  • null
Names
Item Name
Property optionsKeys.childKeys

options-keys.children :string

The key name for the children.
Default Value:
  • null
Names
Item Name
Property optionsKeys.children

options-keys.label :string

The key name for the label.
Default Value:
  • null
Names
Item Name
Property optionsKeys.label

options-keys.value :string

The key name for the value.
Default Value:
  • null
Names
Item Name
Property optionsKeys.value

picker-attributes :Object

Attributes specified here will be set on the picker DOM element when it's launched.

The supported attributes are class and style, which are appended to the picker's class and style, if any. Note: 1) picker-attributes is not applied in the native renderMode. 2) setting this attribute after element creation has no effect.

Default Value:
  • null
Names
Item Name
Property pickerAttributes
Property change event pickerAttributesChanged
Property change listener attribute (must be of type function) on-picker-attributes-changed
Examples

Initialize the select specifying a set of attributes to be set on the picker DOM element:

<oj-select-many picker-attributes="[[pickerAttributes]]"></oj-select-many>
 var pickerAttributes = {
  "style": "color:blue;",
  "class": "my-class"
};

placeholder :string|null|undefined

The placeholder text to set on the element. The placeholder specifies a short hint that can be displayed before user selects a value.
Default Value:
  • null
Names
Item Name
Property placeholder
Property change event placeholderChanged
Property change listener attribute (must be of type function) on-placeholder-changed
Examples

Initialize the select with the placeholder attribute specified:

<oj-select-many placeholder="Please select ..."></oj-select-many>

Get or set the placeholder property after initialization:

// getter
var placeholderValue = mySelect.placeholder;

// setter
mySelect.placeholder = "Select values";

render-mode :string

The render-mode attribute allows applications to specify whether to render select in JET or as a HTML Select tag. Valid Values: jet, native
  • jet - Applications get full JET functionality.
  • native - Applications get the HTML Select tag functionality and additional JET features below:
    • validation
    • placeholder
    • options (ko.observableArray)
    • list
    • optionKeys
    With native renderMode, the functionality that is sacrificed compared to jet rendermode is:
    • no search box (no filtering)
    • for multiple select, only number of selected items is displayed in the selectbox, not the selected values
    • beforeExpand event isn't fired when the popup picker opens.
    • only one level nesting optgroups in the popup picker due to the HTML optgroup limitation
    • no image support in the option list
    • All Sub-IDs are not available in the native renderMode.
    • pickerAttributes is not applied in the native renderMode.
    • when using data provider a maximum of 15 rows will be displayed in the dropdown, users can't filter further.
The default value depends on the theme. In alta-android, alta-ios and alta-windows themes, the default is "native" and it's "jet" for all other themes.
Names
Item Name
Property renderMode
Property change event renderModeChanged
Property change listener attribute (must be of type function) on-render-mode-changed
Examples

Set the render-mode attribute:

<oj-select-many render-mode="native"></oj-select-many>

Get or set the renderMode property after initialization:

// getter
var renderMode = mySelect.renderMode;

// setter
mySelect.renderMode = "native";

required :boolean

Whether the element is required or optional. When required is set to true, an implicit required validator is created using the validator factory - oj.Validation.validatorFactory(oj.ValidatorFactory.VALIDATOR_TYPE_REQUIRED).createValidator(). Translations specified using the translations.required attribute and the label associated with the element, are passed through to the options parameter of the createValidator method.

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

Running Validation

  • if element is valid when required is set to true, then it runs deferred validation on the value. This is to ensure errors are not flagged unnecessarily.
  • if element is invalid and has deferred messages when required is set to false, then element messages are cleared but no deferred validation is run.
  • if element is invalid and currently showing invalid messages when required is set, then element 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 optionChange event on the value property to clear custom errors.

Clearing Messages

  • Only messages created by the element are cleared.
  • messages-custom property is not cleared.

Default Value:
  • false
Since:
  • 0.7
See:
Names
Item Name
Property required
Property change event requiredChanged
Property change listener attribute (must be of type function) on-required-changed
Examples

Initialize the select with the required attribute:

<oj-select-many required="[[isRequired]]"></oj-select-many>

Get or set the required property after initialization:

// getter
var requiredValue = mySelect.required;

// setter
mySelect.required = true;

translations :Object

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 this component has translations, their documentation immediately follows this doc entry.

Default Value:
  • an object containing all resources relevant to the component, or null if none
Names
Item Name
Property translations
Property change event translationsChanged
Property change listener attribute (must be of type function) on-translations-changed
Examples

Initialize the component, overriding some translated resources and leaving the others intact:

<!-- Using dot notation -->
<oj-some-element translations.some-key='some value' translations.some-other-key='some other value'></oj-some-element>

<!-- Using JSON notation -->
<oj-some-element translations='{"someKey":"some value", "someOtherKey":"some other value"}'></oj-some-element>

Get or set the translations property after initialization:

// Get one
var value = myComponent.translations.someKey;

// Set one, leaving the others intact. Always use the setProperty API for 
// subproperties rather than setting a subproperty directly.
myComponent.setProperty('translations.someKey', 'some value');

// Get all
var values = myComponent.translations;

// Set all.  Must list every resource key, as those not listed are lost.
myComponent.translations = {
    someKey: 'some value',
    someOtherKey: 'some other value'
};

translations.filter-further :string

Text at the top of drop down when not all results are fetched and users need to filter further.

Default Value:
  • More results available, please filter further.
Names
Item Name
Property translations.filterFurther

translations.more-matches-found :string

Text for the drop down when more than one options are found.

Default Value:
  • num matches found
Names
Item Name
Property translations.moreMatchesFound

translations.no-matches-found :string

Text for the drop down when no options are found.

Default Value:
  • No matches found
Names
Item Name
Property translations.noMatchesFound

translations.one-matches-found :string

Text for the drop down when one option is found.

Default Value:
  • One match found
Names
Item Name
Property translations.oneMatchesFound

translations.required :Object

Provides properties to customize the summary, detail and hint text used by the implicit required validator associated to any editable component that supports the required option.

See the translations attribute and required option for usage examples.

Since:
  • 0.7
Names
Item Name
Property translations.required

translations.required.hint :string

Hint text used by required validation error.

See the translations attribute for usage examples.

Default Value:
  • ""
Since:
  • 0.7
See:
Names
Item Name
Property translations.required.hint

translations.required.message-detail :string

Message text that describes the details of the required validation error.

See the translations attribute for usage examples.

Default Value:
  • ""
Since:
  • 0.7
See:
Names
Item Name
Property translations.required.messageDetail

translations.required.message-summary :string

Message text for summarizing a required validation error.

See the translations attribute for usage examples.

Default Value:
  • ""
Since:
  • 0.7
See:
Names
Item Name
Property translations.required.messageSummary

translations.search-field :string

Tooltip text for the search box

Default Value:
  • Search field
Names
Item Name
Property translations.searchField

<readonly> valid :string

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

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

  • after validation is run (full or deferred)
  • 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:
Name Type Description
"invalidHidden" string The component has invalid messages hidden and no invalid messages showing. An invalid message is one with severity "error" or higher.
"invalidShown" string The component has invalid messages showing. An invalid message is one with severity "error" or higher.
"pending" string The component is waiting for the validation state to be determined. The "pending" state is never set in this release of JET. It will be set in a future release.
"valid" string The component is valid
Supports writeback:
  • true
Since:
  • 4.2.0
Names
Item Name
Property valid
Property change event validChanged
Property change listener attribute (must be of type function) on-valid-changed
Examples

Get valid attribute, after initialization:

// Getter:
var valid = myComp.valid;

Set the on-valid-changed listener so you can do work in the ViewModel based on the valid property:

<oj-some-element id='username' on-valid-changed='[[validChangedListener]]'>
</oj-some-element>
<oj-some-element id='password' on-valid-changed='[[validChangedListener]]'>
</oj-some-element>
<oj-button disabled='[[componentDisabled]]' on-click='[[submit]]'>Submit</oj-button>
-- ViewModel --
self.validChangedListener = function (event) {
  var enableButton;
  var usernameValidState;
  var passwordValidState;
  
  // update the button's disabled state.
  usernameValidState = document.getElementById("username").valid;
  passwordValidState = document.getElementById("password").valid;
  
  // this updates the Submit button's disabled property's observable based
  // on the valid state of two components, username and password.
  // It is up to the application how it wants to handle the “pending” state 
  // but we think that in general buttons don’t need to be 
  // enabled / disabled based on the "pending" state.
  enableButton = 
   (usernameValidState !== "invalidShown") &&
   (passwordValidState !== "invalidShown");
  self.componentDisabled(!enableButton);;
};

value :Array.<*>

The value of the element. The value is an array with any type of items.
Names
Item Name
Property value
Property change event valueChanged
Property change listener attribute (must be of type function) on-value-changed
Examples

Initialize the select with the value attribute specified:

<oj-select-many value="{{val}}"></oj-select-many>
 var val = ['option1', 'option2'];

Get or set the value property after initialization:

// getter
var value = mySelect.value;

// setter
mySelect.value = ["option1", "option2"];

Events

ojAnimateEnd

Triggered when a default animation has ended.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
action string The action that triggers the animation. Supported values are:
  • "inline-open" - when an inline message container opens or increases in size
  • "inline-close" - when an inline message container closes or decreases in size
  • "notewindow-open" - when a note window opens
  • "notewindow-close" - when a note window closes
element Element The element being animated.
Since:
  • 4.0.0
Examples

Define an event listener for the ojAnimateEnd event to add any processing after the end of "inline-open" animation:

var listener = function( event )
{
  // Check if this is the end of "inline-open" animation for inline message
  if (event.detail.action == "inline-open") {
    // Add any processing here
  }
};

Specify an ojAnimateEnd listener via the DOM attribute:

<oj-select-many on-oj-animate-end='[[listener]]'></oj-select-many>

Specify an ojAnimateEnd listener via the JavaScript property:

mySelectMany.onOjAnimateEnd = listener;

Add an ojAnimateEnd listener via the addEventListener API:

mySelectMany.addEventListener('ojAnimateEnd', listener);

ojAnimateStart

Triggered when a default animation is about to start on an element owned by the component.

The default animation can be cancelled by calling event.preventDefault, followed by a call to ui.endCallback. ui.endCallback should be called immediately after event.preventDefault if the application merely wants to cancel animation, or it should be called when the custom animation ends if the application is invoking another animation function. Failure to call ui.endCallback may prevent the component from working properly.

For more information on customizing animations, see the documentation of oj.AnimationUtils.

The default animations are controlled via the theme (SCSS) :

// default animations for "notewindow" display option
$noteWindowOpenAnimation: (effect: "zoomIn", transformOrigin: "#myPosition") !default;
$noteWindowCloseAnimation: (effect: "none") !default;

// default animations for "inline" display option
$messageInlineOpenAnimation: (effect: "expand", startMaxHeight: "#oldHeight") !default;
$messageInlineCloseAnimation: (effect: "collapse", endMaxHeight: "#newHeight") !default;
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
action string The action that triggers the animation. Supported values are:
  • "inline-open" - when an inline message container opens or increases in size
  • "inline-close" - when an inline message container closes or decreases in size
  • "notewindow-open" - when a note window opens
  • "notewindow-close" - when a note window closes
element Element The element being animated.
endCallback function If the event listener calls event.preventDefault to cancel the default animation, it must call the endCallback function when it finishes its own animation handling and any custom animation has ended.
Since:
  • 4.0.0
Examples

Define an event listener for the ojAnimateStart event to override the default "inline-open" animation:

var listener = function( event )
  {
    // Change the "inline-open" animation for inline message
    if (event.detail.action == "inline-open") {
      // Cancel default animation
      event.preventDefault();
      // Invoke new animation and call endCallback when the animation ends
      oj.AnimationUtils.fadeIn(event.detail.element).then(event.detail.endCallback);
    }
  };

Define an event listener for the ojAnimateStart event to cancel the default "notewindow-close" animation:

var listener = function( event )
  {
    // Change the "notewindow-close" animation for note window
    if (ui.action == "notewindow-close") {
      // Cancel default animation
      event.preventDefault();
      // Call endCallback immediately to indicate no more animation
      event.detail.endCallback();
  };

Specify an ojAnimateStart listener via the DOM attribute:

<oj-select-many on-oj-animate-start='[[listener]]'></oj-select-many>

Specify an ojAnimateStart listener via the JavaScript property:

mySelectMany.onOjAnimateStart = listener;

Add an ojAnimateStart listener via the addEventListener API:

mySelectMany.addEventListener('ojAnimateStart', listener);

Methods

blur() → {undefined}

Blurs the element that naturally gets focus. For example, this would be the input element for input type components.
Since:
  • 4.2
Returns:
Type
undefined
Example

Calling blur on a custom element will call blur on the appropriate child element

var elem = document.getElementById("myId");
elem.blur();

focus() → {undefined}

Sets focus on the element that naturally gets focus. For example, this would be the input element for input type components.
Since:
  • 4.2
Returns:
Type
undefined
Example

Calling focus on a custom element will call focus on the appropriate child element

var elem = document.getElementById("myId");
elem.focus();

getProperty(property) → {*}

Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description
property string The property name to get. Supports dot notation for subproperty access.
Returns:
Type
*
Example

Get a single subproperty of a complex property:

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

refresh()

Refreshes the visual state of the select. JET elements require a refresh() after the DOM is programmatically changed.

This method does not accept any arguments.

reset()

Resets the component by clearing all messages and messages attributes - messagesCustom - and updates the component's display value using the attribute value. User entered values will be erased when this method is called.
Since:
  • 0.7
Example

Reset component

myComp.reset(); 

setProperties(properties)

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

Set a batch of properties:

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

setProperty(property, value)

Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description
property string The property name to set. Supports dot notation for subproperty access.
value * The new value to set the property to.
Example

Set a single subproperty of a complex property:

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

showMessages()

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.

Since:
  • 0.7
Example

Display all messages including deferred ones.

myComp.showMessages();

validate() → {Promise}

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

  1. All messages are cleared, including custom messages added by the app.
  2. The implicit required validator is run first 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 option is updated.
Returns:
Promise resolves to "valid" if the component passed validation. The Promise resolves to "invalid" if there were validation errors.
Type
Promise
Examples

Validate component using its current value.

myComp.validate();

Validate component and use the Promise's resolved state.

myComp.validate().then(
 function(result) {
   if(result === "valid")
   {
     submitForm();
   }
 });