Class: editableValue

Oracle® JavaScript Extension Toolkit (JET)
1.1.2

E65298-01

QuickNav

Options


Non-public Fields (internal use only)
Binding Attributes

oj. editableValue extends oj.baseComponent

Version:
  • 1.1.2
Since:
  • 0.6
Abstract base class for all editable components that are value holders and that require validation and messaging capabilities.

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 options are cleared - messagesShown, messagesHidden and messagesCustom options.
    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 messagesShown option is updated 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 messagesShown option is updated and processing returns. If there are no errors, then the value option 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 for details.
  • When certain options 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, 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 deferred validation is run and no messages options are cleared prior to running validation. Refer to the Validators Participating in Deferred Validation section for details.
  • When the value option changes due to programmatic intervention deferred validation is run, after all messages options - messagesShown, messagesHidden and messagesCustom - are cleared.
  • When the reset method is called, deferred validation is run after all messages options - messagesShown, messagesHidden and messagesCustom - are cleared.
  • When certain options 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 converter option changes. See converter option for details.
  • when disabled option changes. See disabled option for details.
  • when required option changes. See required option for details.
  • when validators option changes. See validators option for details.
  • when refresh method is called. See refresh method 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.

Declarative Binding

When the component's value option is bound to a Knockout observable and when the value changes, whether the observable is updated or not, iow whether a 'writeback' to the observable happens or not, depends on the action that caused the value to change.
  • when the value changes as a result of user interaction
  • when the value changes because normal validation was run as a result of these options being changed by the app - converter, disabled, required, validators, then the value is written to the observable. See the specific option docs for details.
  • when the value changes because normal validation was run as a result of these methods being called by the app - refresh, validate, then the value is written to the observable. See the specific method docs for details.
  • when the value changes due to programmatic intervention by app then the value is not written back to observable. This is based on the assumption that the app has mutated the observable already. In this case updating the component's value option alone will not propagate the change automatically to the observable. Updating the observable is recommended as this will propagate the change automatically to the component.

Initializer

<abstract> .editableValue()

Source:
Examples

Initialize component

<input id="foo" type="text"/>
<script>
  $('#foo").ojInputText({'value': 'abc'});
</script>
// using knockout ojComponent binding
<input id="foo" data-bind="ojComponent: {component: 'ojInputText', value: 'abc'}"/>

Initialize component value using ko observable

<input id="foo" data-bind="ojComponent: {component: 'ojInputText', value: salary}"/>
<script>
  var salary = ko.observable('abc');
</script>

Initialize component value using element value

<input id="foo" data-bind="ojComponent: {component: 'ojInputText'}" value='abc'/>

Options

contextMenu :Object

JQ selector identifying the JET Menu that the 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 specified JET Menu.

To specify a JET context menu on a DOM element that is not a JET component, see the ojContextMenu binding.

To make the page semantically accurate from the outset, applications are encouraged to specify the context menu via the standard HTML5 syntax shown in the below example. When the component is initialized, the context menu thus specified will be set on the component.

After create time, the contextMenu option should be set via this API, not by setting the DOM attribute.

Default Value:
  • null
Inherited From:
Source:
Examples

Initialize a JET component with a context menu:

// via recommended HTML5 syntax:
<div id="myComponent" contextmenu="myMenu" data-bind="ojComponent: { ... }>

// via JET initializer (less preferred) :
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "contextMenu": "#myMenu" });

Get or set the contextMenu option, after initialization:

// getter
// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
var menu = $( ".selector" ).ojFoo( "option", "contextMenu" );

// setter
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "option", "contextMenu", ".my-marker-class" );

Set a JET context menu on an ordinary HTML element:

<a href="#" id="myAnchor" contextmenu="myMenu" data-bind="ojContextMenu: {}">Some text

disabled :boolean

Whether the component is disabled. The element's disabled property is used as its initial value if it exists, when the option is not explicitly set. When neither is set, disabled defaults to false.

The 2-way disabled binding offered by the ojComponent binding should be used instead of Knockout's built-in disable and enable bindings, as the former sets the API, while the latter sets the underlying DOM attribute.

When the disabled option 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: null, required:true, disabled: true}, 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 pushed to messagesShown option.
      • if no errors result from the validation, the value option is updated. Page authors can listen to the optionChange event on the value option 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 messagesHidden option 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 messagesHidden option is updated.
  • when enabled component is disabled then no validation is run and the component appears disabled.

Default Value:
  • false
Source:
Example

Initialize component with disabled option:

$(".selector").ojFoo({"disabled": true}); // Foo is InputText, InputNumber, Select, etc.

displayOptions :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 title.
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 displayOptions changes due to programmatic intervention, the component updates its display to reflect the updated choices. For example, if 'title' property goes from 'notewindow' to 'none' then it no longer shows in the notewindow.

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'}}
title Array | string <optional>
supported values are 'notewindow', 'none'. To change the default value you can do this -
E.g. {'displayOptions: {'title': 'none'}}
Default Value:
  • {
      'messages': ['inline'],
      'converterHint': ['placeholder', 'notewindow'],
      'validatorHint': ['notewindow'],
      'title': ['notewindow']
    }
Since:
  • 0.7
Source:
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 displayOptions for one component instance:

// In this example, the instance of ojFoo changes its displayOptions from the defaults.
// The 'converterHint' is none, the 'validatorHint' is none and the 'title' 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).
//
// Foo is InputText, InputNumber, Select, etc.
$(".selector").ojFoo("option", "displayOptions", {
  'converterHint': 'none',
  'validatorHint': 'none',
  'title' : 'none'
});

help :Object.<string, string>

Help information that goes on the label. When help is set on the input component, then help information is added to the input's label.

The properties supported on the help option are:

Properties:
Name Type Argument Description
definition string <optional>
this is the help definition text. It is what shows up when the user hovers over the label or 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 because the help definition renders on title attribute. The default value is null.
source string <optional>
this is the help source url. If present, the help icon's anchor's target is this source. 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. The default value is null.
Default Value:
  • {help : {definition :null, source: null}}
Source:
Examples

Initialize the input with the help definition and external url information:

// Foo is InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "help": {"definition":"some help definition, "source":"some external url" } });

Set the help option, after initialization:

// setter
// Foo is InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "option", "help", {"definition":"fill out the name", "source":"http:\\www.oracle.com" } );

help.definition :string

help definition text. See the top-level help option for details.

Default Value:
  • null
Source:
Example

Get or set the help.definition sub-option, after initialization:

// getter
var definitionText = $( ".selector" ).ojFoo( "option", "help.definition" );

// setter:
$( ".selector" ).ojFoo( "option", "help.definition", "Enter your name" );

help.source :string

help source url. See the top-level help option for details.

Default Value:
  • null
Source:
Example

Get or set the help.source sub-option, after initialization:

// getter
var helpSource = $( ".selector" ).ojFoo( "option", "help.source" );

// setter:
$( ".selector" ).ojFoo( "option", "help.source", "www.abc.com" );

messagesCustom :Array|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 messagesShown option is also updated.
Each message in the array is either an instance of oj.Message or an object that duck types it. See oj.Message for details.

An optionChange event is triggered every time this option value changes.

Default Value:
  • empty array when no option is set.
Since:
  • 0.7
Source:
See:
Examples

Get the current list of app messages using messagesCustom option:

// Foo is InputText, InputNumber, Select, etc.
var customMsgs = $(".selector").ojFoo("option", "messagesCustom"); 

Clear all app messages set on the component:

// Foo is InputText, InputNumber, Select, etc.
$(".selector").ojFoo("option", "messagesCustom", []); 

Set app messages using the messagesCustom option:

var msgs = [];
msgs.push({'summary': 'Error Summary', 'detail': 'Error Detail'}); 
// Foo is InputText, InputNumber, Select, etc.
$(".selector").ojFoo("option", "messagesCustom", msgs);

<readonly> messagesHidden :Array|undefined

List of messages currently hidden on component, these are added by component when it runs deferred validation. Each message in the array is either an instance of oj.Message or an object that duck types it. See oj.Message for details.

This is a read-only option so page authors cannot set or change it directly.

An optionChange event is triggered every time this option value changes.

These messages are not shown to the end-user by default, but page author can show hidden messages using the showMessages method.

Default Value:
  • empty array when no option is set.
Since:
  • 0.7
Source:
See:
Example

Get messagesShown for the component:

// Foo is InputText, InputNumber, Select, etc.
var messages = $(".selector").ojFoo("option", "messagesShown"); 

<readonly> messagesShown :Array|undefined

List of messages currently shown on component, these include messages generated both by the component and ones provided by app using messagesCustom. Each message in the array is either an instance of oj.Message or an object that duck types it. See oj.Message for details.

This is a read-only option so page authors cannot set or change it directly.

An optionChange event is triggered every time its value changes.

Messages retrieved using the messagesShown option are by default shown in the notewindow, but this can be controlled using the 'messages' property of the displayOptions option.

Default Value:
  • empty array when no option is set.
Since:
  • 0.7
Source:
Example

Get messagesShown for the component:

// Foo is InputText, InputNumber, Select, etc.
var messages = $(".selector").ojFoo("option", "messagesShown"); 

required :boolean|undefined

Whether the component 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 option and the label associated with the component, are passed through to the options parameter of the createValidator method.

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

Running Validation

  • if component is valid when required is set to true, then it runs deferred validation on the option value. This is to ensure errors are not flagged unnecessarily.
    • if there is a deferred validation error, then messagesHidden option is updated.
  • if component is invalid and has deferred messages when required is set to false, then component messages are cleared but no deferred validation is run.
  • if component is invalid and currently showing invalid messages when required is set, then component messages are cleared and normal validation is run using the current display value.
    • if there are validation errors, then value option is not updated and the error pushed to messagesShown option.
    • if no errors result from the validation, the value option is updated; page author can listen to the optionChange event on the value option to clear custom errors.

Clearing Messages

  • Only messages created by the component are cleared. These include ones in messagesHidden and messagesShown options.
  • messagesCustom option is not cleared.

Supported Values:
Name Type Description
false boolean implies a value is not required to be provided by the user. This is the default.
true boolean implies a value is required to be provided by user and the input's label will render a required icon. Additionally a required validator - oj.RequiredValidator - is implicitly used if no explicit required validator is set. An explicit required validator can be set by page authors using the validators option.
Default Value:
  • when the option is not set, the element's required property is used as its initial value if it exists.
Since:
  • 0.7
Source:
See:
Examples

Initialize the component with the required option:

$(".selector").ojFoo({required: true}); // Foo is InputText, InputNumber, Select, etc.

Initialize required option from html attribute 'required':

<input type="text" value= "foobar" required/>
// retreiving the required option returns true $(".selector").ojFoo("option", "required"); // Foo is InputText, InputNumber, Select, etc.

Customize messages and hints used by implicit required validator when required option is set:

<!-- Foo is InputText, InputNumber, Select, etc. -->
<input type="text" value="foobar" required data-bind="ojComponent: {
  component: 'ojFoo', 
  value: password, 
  translations: {'required': {
                hint: 'custom: enter at least 3 alphabets',
                messageSummary: 'custom: \'{label}\' is Required', 
                messageDetail: 'custom: please enter a valid value for \'{label}\''}}}"/>

rootAttributes :Object

Attributes specified here will be set on the component's root DOM element at creation time. This is particularly useful for components like Dialog that wrap themselves in a new root element at creation time.

The supported attributes are id, which overwrites any existing value, and class and style, which are appended to the current class and style, if any.

Setting this option after component creation has no effect. At that time, the root element already exists, and can be accessed directly via the widget method, per the second example below.

Default Value:
  • null
Inherited From:
Source:
Examples

Initialize a JET component, specifying a set of attributes to be set on the component's root DOM element:

// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "rootAttributes": {
  "id": "myId",
  "style": "max-width:100%; color:blue;",
  "class": "my-class"
}});

After initialization, rootAttributes should not be used. It is not needed at that time, as attributes of the root DOM element can simply be set directly, using widget:

// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "widget" ).css( "height", "100px" );
$( ".selector" ).ojFoo( "widget" ).addClass( "my-class" );

title :string|undefined

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

When a title is present it is by default displayed in the notewindow, or as determined by the 'title' property set on the displayOptions option. When the title option changes the component refreshes to display the new title.

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

<html>Enter <b>at least</b> 6 characters</html>
Default Value:
  • when the option is not set, the element's title attribute is used as its initial value if it exists.
Source:
Examples

Initialize the component with the title option:

<!-- Foo is InputText, InputNumber, Select, etc. -->
<input id="username" type="text" data-bind="
   ojComponent: {component: 'ojFoo', title : 'enter at least 3 alphanumeric characters', 
                 pattern: '[a-zA-Z0-9]{3,}', value: ''}"/>

Initialize title option from html attribute 'title':

<!-- Foo is InputText, InputNumber, Select, etc. -->
<input id="username" type="text" value= "foobar" title="enter at least 3 alphanumeric characters" 
          pattern="[a-zA-Z0-9]{3,}"/>
$("#username").ojFoo({}); // Foo is InputText, InputNumber, Select, etc. // reading the title option will return "enter at least 3 alphanumeric characters" $("#username").ojFoo("option", "title"); // Foo is InputText, InputNumber, Select, etc.

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 (or inherits) translations, their documentation immediately follows this doc entry.

Default Value:
  • an object containing all resources relevant to the component and all its superclasses, or null if none
Inherited From:
Source:
Examples

Initialize the component, overriding some translated resources. This syntax leaves the other translations intact at create time, but not if called after create time:

// Foo is InputDate, InputNumber, etc.
$( ".selector" ).ojFoo({ "translations": { someKey: "someValue",
                                           someOtherKey: "someOtherValue" } });

Get or set the translations option, after initialization:

// Get one.  (Foo is InputDate, InputNumber, etc.)
var value = $( ".selector" ).ojFoo( "option", "translations.someResourceKey" );

// Get all.  (Foo is InputDate, InputNumber, etc.)
var values = $( ".selector" ).ojFoo( "option", "translations" );

// Set one, leaving the others intact.  (Foo is InputDate, InputNumber, etc.)
$( ".selector" ).ojFoo( "option", "translations.someResourceKey", "someValue" );

// Set many.  Any existing resource keys not listed are lost.  (Foo is InputDate, InputNumber, etc.)
$( ".selector" ).ojFoo( "option", "translations", { someKey: "someValue",
                                                    someOtherKey: "someOtherValue" } );

translations.required :Object

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

See the translations option and required option for usage examples.

Since:
  • 0.7
Source:

translations.required.hint :string

Hint text used by required validation error.

See the translations option for usage examples.

Default Value:
  • ""
Since:
  • 0.7
Source:
See:

translations.required.messageDetail :string

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

See the translations option for usage examples.

Default Value:
  • ""
Since:
  • 0.7
Source:
See:

translations.required.messageSummary :string

Message text for summarizing a required validation error.

See the translations option for usage examples.

Default Value:
  • ""
Since:
  • 0.7
Source:
See:

validators :Array|undefined

List of validators used by component when performing validation. Each item is either an instance that duck types oj.Validator, or is an Object literal containing the properties listed below. Implicit validators created by a component when certain options are present (e.g. required option), are separate from validators specified through this option. At runtime when the component runs validation, it combines the implicit validators with the list specified through this option.

Hints exposed by validators are shown in the notewindow by default, or as determined by the 'validatorHint' property set on the displayOptions option.

When validators option changes due to programmatic intervention, the component may decide to clear messages and run validation, based on the current state it is in.

Steps Performed Always

  • The cached list of validator instances are cleared and new validator hints is pushed to messaging. E.g., notewindow displays the new hint(s).

Running Validation

  • if component is valid when validators changes, component does nothing other than the steps it always performs.
  • if component is invalid and is showing messages - messagesShown option is non-empty, when validators changes then all component messages are cleared and full validation run using the display value on the component.
    • if there are validation errors, then value option is not updated and the error pushed to messagesShown option.
    • if no errors result from the validation, the value option is updated; page author can listen to the optionChange event on the value option to clear custom errors.
  • if component is invalid and has deferred messages when validators changes, it does nothing other than the steps it performs always.

Clearing Messages

  • Only messages created by the component are cleared. These include ones in messagesHidden and messagesShown options.
  • messagesCustom option is not cleared.

Properties:
Name Type Argument Description
type string the validator type that has a oj.ValidatorFactory that can be retrieved using the oj.Validation module. For a list of supported validators refer to oj.ValidatorFactory.
E.g., {validators: [{type: 'regExp'}]}
options Object <optional>
optional Object literal of options that the validator expects.
E.g., {validators: [{type: 'regExp', options: {pattern: '[a-zA-Z0-9]{3,}'}}]}
Source:
Examples

Initialize the component with validator object literal:

// Foo is InputText, InputNumber, Select, etc.
$(".selector").ojFoo({
  validators: [{
    type: 'numberRange', 
    options : {
      hint: {min: 'Enter a value greater than {min}'}, 
      min: 100
    }
  }],
});

NOTE: oj.Validation.validatorFactory('numberRange') returns the validator factory that is used 
to instantiate a range validator for numbers.

Initialize the component with multiple validator instances:

var validator1 = new MyCustomValidator({'foo': 'A'}); 
var validator2 = new MyCustomValidator({'foo': 'B'});
// Foo is InputText, InputNumber, Select, etc.
$(".selector").ojFoo({
  value: 10, 
  validators: [validator1, validator2]
});

value :Object|undefined

The value of the component.

When value option changes due to programmatic intervention, the component always clears all messages - messagesHidden, messagesShown and messagesCustom, runs deferred validation, and always refreshes UI display value.

Running Validation

  • component always runs deferred validation; if there is a validation error the messagesHidden option is updated.

Default Value:
  • When the option is not set, the element's dom value is used as its initial value if it exists. The type of value is as defined by the component that extends this class. Refer to specific components for defaults.
Source:
Examples

Initialize the component with the value option specified:

$(".selector").ojFoo({'value': '10'}); // Foo is InputText, InputNumber, Select, etc.

Get or set value option, after initialization:

// Getter: returns '10'
$(".selector").ojFoo("option", "value");// Foo is InputText, InputNumber, Select, etc.
// Setter: sets '20'
$(".selector").ojFoo("option", "value", '20'); // Foo is InputText, InputNumber, Select, etc.

Non-public Fields

Note: Extending JET components is not currently supported. Thus, non-public fields are for internal use only.

<protected, static, constant> _VALIDATE_METHOD_OPTIONS :Object

Default options used by validate method.
Source:
See:

<protected, static, constant> _VALIDATION_CONTEXT :Object

The context the component can be in when validation is run.
  • COMPONENT_CREATE - when component is created and we run validators. usually messages are not displayed right away, i.e, are 'deferred'.
  • VALUE_OPTION_CHANGE - when component's value is updated programmatically. messages are deferred.
  • REQUIRED_OPTION_CHANGE - when component's required option is updated programmatically. messages are deferred.
  • USER_ACTION - when component runs validation as a result of user interating with component. messages are displayed immediately.
  • VALIDATE_METHOD - when component's validate() method is called explicitly. messages are displayed immediately.
Source:

<protected, static, constant> _VALIDATION_MODE :Object

Validation mode specifying the kind of validation that gets run.
  • FULL - the default and runs both the converter and all validators.
  • VALIDATORS_ONLY - runs all validators including the required validator is run.
  • REQUIRED_VALIDATOR_ONLY - runs just the required validator.
Source:

Binding Attributes

Binding attributes are similar to component options, but are exposed only via the ojComponent binding.

invalidComponentTracker :oj.InvalidComponentTracker

When this attribute is bound to an observable, the framework pushes an object of type oj.InvalidComponentTracker onto the observable. The object itself tracks the validity of a group of editable components.

When this attribute is present, the binding registers a listener for the optionChange event. This event is fired by JET editable components whenever its validity changes (i.e. when messagesShown or messagesHidden options change). When the event is fired, the listener determines the current validity of the component and updates the tracker.

The observable bound to this attribute is often used with multiple component binding declarations as shown in the example below.

This attribute is only exposed via the ojComponent binding, and is not a component option.

Default Value:
  • null
Since:
  • 0.7
Source:
Examples

Track validity of multiple components using a single observable bound to the invalidComponentTracker attribute:

<input id="username" type="text" name="username" required 
  data-bind="ojComponent: {component: 'ojInputText', value: userName, 
                           invalidComponentTracker: tracker}">

<input id="password" type="password" name="password" required 
  data-bind="ojComponent: {component: 'ojInputPassword', value: password, 
                           invalidComponentTracker: tracker}"/>
  
// ViewModel that defines the tracker observable
<script>
function MemberViewModel() 
{ 
  var self = this;
  
  self.tracker = ko.observable();
  
  self.userName = ko.observable();   
  self.password = ko.observable();
}
</script>

Use tracker property invalid to disable button:

// button is disabled if there are components currently showing errors
<button type="button" data-bind="ojComponent: {component: 'ojButton', label: 'Submit',
                                               disabled: tracker()['invalidShown']}">

Events

destroy

Triggered before the component is destroyed. This event cannot be canceled; the component will always be destroyed regardless.

Inherited From:
Source:
Examples

Initialize component with the destroy callback

// Foo is Button, InputText, etc.
$(".selector").ojFoo({
  'destroy': function (event, data) {}
});

Bind an event listener to the destroy event

$(".selector").on({
  'ojdestroy': function (event, data) {
      window.console.log("The DOM node id for the destroyed component is : %s", event.target.id);
  };
});

optionChange

Triggered when any option changes. The event payload has the following properties:

Properties:
Name Type Description
event Event jQuery event object
data Object event payload
Properties
Name Type Description
option string the name of the option that changed.
previousValue Object an Object holding the previous value of the option. When previousValue is not a primitive type, i.e., is an Object, it may hold the same value as the value property.
value Object an Object holding the current value of the option.
optionMetadata Object information about the option that changed
Properties
Name Type Description
writeback string "shouldWrite" or "shouldNotWrite". For use by the JET writeback mechanism; 'shouldWrite' indicates that the value should be written to the observable.
Inherited From:
Source:
Examples

Initialize component with the optionChange callback

// Foo is Button, InputText, etc.
$(".selector").ojFoo({
  'optionChange': function (event, data) {}
});

Bind an event listener to the ojoptionchange event

$(".selector").on({
  'ojoptionchange': function (event, data) {
      window.console.log("option that changed is: " + data['option']);
  };
});

Methods

getNodeBySubId(locator) → {Element|null}

Return the subcomponent node represented by the documented locator attribute values.
If the locator is null or no subId string is provided then this method returns the element that this component was initalized with.
If a subId was provided but a subcomponent node cannot be located this method returns null.

If the locator or its subId is null, then this method returns the element on which this component was initalized.

If a subId was provided but no corresponding node can be located, then this method returns null.

Parameters:
Name Type Description
locator Object An Object containing, at minimum, a subId property. See the table for details on its fields.
Properties:
Name Type Argument Description
locator.subId string <optional>
A string that identifies a particular DOM node in this component.

The supported sub-ID's are documented in the Sub-ID's section of this document.

locator.index number <optional>
A zero-based index, used to locate a message content node or a hint node within the popup.
Source:
Returns:
The DOM node located by the subId string passed in locator, or null if none is found.
Type
Element | null
Example

Get the node for a certain subId:

// Foo is ojInputNumber, ojInputDate, etc.
var node = $( ".selector" ).ojFoo( "getNodeBySubId", {'subId': 'oj-some-sub-id'} );

isValid() → {boolean}

whether the component is currently valid.
Source:
Returns:
Type
boolean
Example

Check whether the component is valid:

var value = $(".selector").ojInputText("isValid");

option(optionName, value) → {Object|undefined}

This method has several overloads, which get and set component options and their fields. The functionality is unchanged from that provided by JQUI. See the examples for details on each overload.

Parameters:
Name Type Argument Description
optionName string | Object <optional>
the option name (string, first two overloads), or the map (Object, last overload). Omitted in the third overload.
value Object <optional>
a value to set for the option. Second overload only.
Inherited From:
Source:
Returns:
The getter overloads return the retrieved value(s). When called via the public jQuery syntax, the setter overloads return the object on which they were called, to facilitate method chaining.
Type
Object | undefined
Examples

First overload: get one option:

This overload accepts a (possibly dot-separated) optionName param as a string, and returns the current value of that option.

var isDisabled = $( ".selector" ).ojFoo( "option", "disabled" ); // Foo is Button, Menu, etc.

// For object-valued options, dot notation can be used to get the value of a field or nested field.
var startIcon = $( ".selector" ).ojButton( "option", "icons.start" ); // icons is object with "start" field

Second overload: set one option:

This overload accepts two params: a (possibly dot-separated) optionName string, and a new value to which that option will be set.

$( ".selector" ).ojFoo( "option", "disabled", true ); // Foo is Button, Menu, etc.

// For object-valued options, dot notation can be used to set the value
// of a field or nested field, without altering the rest of the object.
$( ".selector" ).ojButton( "option", "icons.start", myStartIcon ); // icons is object with "start" field

Third overload: get all options:

This overload accepts no params, and returns a map of key/value pairs representing all the component options and their values.

var options = $( ".selector" ).ojFoo( "option" ); // Foo is Button, Menu, etc.

Fourth overload: set one or more options:

This overload accepts a single map of option-value pairs to set on the component. Unlike the first two overloads, dot notation cannot be used.

$( ".selector" ).ojFoo( "option", { disabled: true, bar: 42 } ); // Foo is Button, Menu, etc.

refresh()

Called when the DOM underneath the component chages requiring a re-render of the component. An example is when the label for the input changes.

Another time when refresh might be called is when the locale for the page changes. When it changes, options used by its converter and validator that are locale specific, its hints, messages and translations will be updated.

When refresh method is called, the component may take various steps such as clearing messages, running validation etc., based on the state it is in.

Steps Performed Always

  • The converter and validators used by the component are reset, and new converter and validator hints is pushed to messaging. E.g., notewindow displays the new hint(s).

Running Validation

  • if component is valid when refresh() is called, the display value is refreshed if component has a converter set.
  • if component is invalid and is showing messages - messagesShown option is non-empty, when refresh() is called, then all component messages are cleared and full validation run using the display value on the component.
    • if there are validation errors, then value option is not updated and the error pushed to messagesShown option.
    • if no errors result from the validation, the value option is updated; page author can listen to the optionChange event on the value option to clear custom errors.
  • if component is invalid and has deferred messages when refresh() is called, then all component messages are cleared and deferred validation is run.

Clearing Messages

  • If clearing messages only those created by the component are cleared. These include ones in messagesHidden and messagesShown options.
  • messagesCustom option is not cleared.

Since:
  • 0.7
Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
Example

Refresh component after changing the label DOM.

// Foo is ojInputNumber, ojInputText, etc.
$(selector).ojFoo("refresh");

reset()

Resets the component by clearing all messages options - messagesCustom, messagesHidden and messagesShown, and updates the component's display value using the option value. User entered values will be erased when this method is called.
Since:
  • 0.7
Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
Example

Reset component

$(selector).ojInputText("reset"); 

showMessages()

Takes all hidden messages that are in the messagesHidden option and moves them to messagesShown option. If there were no messages in messagesHidden then this method simply returns.

To view messages user has to set focus on the component.

An optionChange event is triggered on both messagesHidden and messagesShown options.

Since:
  • 0.7
Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
Example

Display all messages including deferred ones.

$(selector).ojInputText("showMessages");

validate() → {boolean}

Validates the component's display value using the converter and 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. 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 messagesShown option is updated and method returns false.
  3. If there are no validators setup for the component the value option is updated using the display value and the method returns true. Otherwise all validators are run in sequence using the parsed value from the previous step. The implicit required validator 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.
  4. At the end of validation if there are errors, the messagesShown option is updated and method returns false. If there were no errors, then the value option is updated and method returns true.
Since:
  • 0.7
Deprecated:
  • param 'requiredOnly' has been deprecated since version 0.7.
    Source:
    Returns:
    true if component passed validation, false if there were validation errors.
    Type
    boolean
    Example

    Validate component using its current value.

    // validate display value. 
    $(.selector).ojInputText('validate');

    Non-public Methods

    Note: Extending JET components is not currently supported. Thus, non-public methods are for internal use only.

    <protected> _AfterCreate()

    The value option alone is initialized here since it requires the component to be fully created. Calling this.options.value before this method does not guarantee the correct value to be returned.
    Source:

    <protected> _AfterCreateEvent()

    This method is called after the create event is fired. Components usually should not override this method, as it is rarely correct to wait until after the create event to perform a create-time task.

    An example of a correct usage of this method is Dialog's auto-open behavior, which needs to happen after the create event.

    Only behaviors (like Dialog auto-open behavior) should occur in this method. Component initialization must occur earlier, before the create event is fired, so that create listeners see a fully inited component.

    Overrides of this method should call this._super first.

    Do not confuse this method with the _AfterCreate method, which is more commonly used.

    Inherited From:
    Source:

    <protected> _AfterSetOption(option, flags)

    Performs post processing after _SetOption() is called. Different options when changed perform different tasks.
    Parameters:
    Name Type Argument Description
    option string
    flags Object <optional>
    Source:

    <protected> _AfterSetOptionConverter(option)

    Performs post processing after converter option changes by taking the following steps. - always push new converter hint to messaging
    - if component has no errors -> refresh UI value
    - if component is invalid has messagesShown -> clear all component errors and run full validation using display value.
      - if there are validation errors, value is not pushed to model; messagesShown is updated.
      - if no errors result from the validation, push value to model; author needs to listen to optionChange(value) to clear custom errors.
    - if component is invalid has messagesHidden -> refresh UI value. no need to run deferred validations.
    - messagesCustom is never cleared
    Parameters:
    Name Type Description
    option String
    Source:

    <protected> _AfterSetOptionDisabledReadOnly(option, validationOptions)

    Performs post processing after disabled or readOnly option changes by taking the following steps. (Steps are same for readOnly option).

    if disabled component is enabled then,
    - if there are no errors, run deferred validation. component could have been initialized with empty value and disabled.
    - if component is invalid and showing messages clear component error, grab UI value and run full validation.
    - if component is invalid and has hidden messages; do nothing.

    if enabled component is disabled no validation is run.

    Parameters:
    Name Type Description
    option String
    validationOptions Object
    Source:

    <protected> _AfterSetOptionRequired(option)

    Performs post processing after required option is set by taking the following steps. - if component is invalid and has messgesShown -> required: false/true -> clear component errors; run full validation with UI value (we don't know if the UI error is from a required validator or something else);
      - if there are validation errors, then value not pushed to model; messagesShown is updated
      - if no errors result from the validation, push value to model; author needs to listen to optionChange(value) to clear custom errors.
    - if component is invalid and has messagesHidden -> required: false -> clear component errors; no deferred validation is run.
    - if component has no error -> required: true -> run deferred validation (we don't want to flag errors unnecessarily)
    - messagesCustom is never cleared
    Parameters:
    Name Type Description
    option string
    Source:

    <protected> _AfterSetOptionValidators() → {undefined}

    When validators option changes, take the following steps. - Clear the cached normalized list of all validator instances. push new hints to messaging.
    - if component is valid -> validators changes -> no change
    - if component is invalid has messagesShown -> validators changes -> clear all component messages and re-run full validation on displayValue. if there are no errors push value to model;
    - if component is invalid has messagesHidden -> validators changes -> do nothing; doesn't change the required-ness of component
    - messagesCustom is not cleared.
    NOTE: The behavior applies to any option that creates implicit validators - min, max, pattern, etc. Components can call this method when these options change.
    Source:
    Returns:
    Type
    undefined

    <protected> _AfterSetOptionValue(option, flags)

    Performs post processing after value option changes by taking the following steps. - triggers an optionChange and does writeback if required.
    - if setOption was from programmatic intervention,
      - clear custom messages and component messages;
      - run deferred validation. if there is an error, updates messagesHidden.
    - always refreshes UI display
    Parameters:
    Name Type Argument Description
    option string
    flags Object <optional>
    Source:

    <protected> _AriaRequiredUnsupported()

    Called to find out if aria-required is unsupported. This is needed for the label. It is not legal to have aria-required on radio/checkboxes, nor on radiogroup/group.
    Source:

    <protected> _CanSetValue()

    Whether the a value can be set on the component. If the component is disabled or readOnly then setting value on component is a no-op.
    Source:
    See:

    <protected> _ClearPlaceholder()

    Clear the placeholder option
    Source:

    <protected> _CompareOptionValues(option, value1, value2) → {boolean}

    Compares 2 option values for equality and returns true if they are equal; false otherwise.

    Parameters:
    Name Type Description
    option String the name of the option
    value1 Object first value
    value2 Object another value
    Inherited From:
    Source:
    Returns:
    Type
    boolean

    <protected> _ComponentCreate()

    Initializes options defined by this base class.
    Source:

    <protected> _create()

    This method is final in JET. Components should instead override one or more of the overridable create-time methods listed in _ComponentCreate.

    Inherited From:
    Source:

    <protected> _destroy()

    Detaches the widget from the element and restores element exactly like it was before the widget was attached.
    Source:

    <protected> _formatValue(value) → {string}

    Formats the value for display, based on the converter options. If no converter is set then returns the value as is.
    Parameters:
    Name Type Description
    value string value to be formatted
    Source:
    Throws:
    when an error occurs during formatting
    Type
    Error
    Returns:
    formatted value
    Type
    string

    <protected> _GetAllValidators() → {Array}

    Returns an array of all validators built by merging the validators option set on the component and the implicit validators setup by the component.
    This does not include the implicit required validator. Components can override to add to this array of validators.
    Source:
    Returns:
    of validators
    Type
    Array

    <protected> _GetContentElement() → {Object}

    Returns a jquery object of the element representing the content node. This could be a jQuery object of the element the widget was invoked on - typically this is an input or select or textarea element for which a value can be set.
    Source:
    Returns:
    the jquery element that represents the editable content. E.g., an input
    Type
    Object

    <protected> _GetConverter() → {Object}

    Returns the normalized converter instance.
    Source:
    Returns:
    a converter instance or null
    Type
    Object

    <protected> _getCreateOptions()

    This method is not used in JET. Components should instead override _InitOptions.

    Inherited From:
    Source:

    <abstract, protected> _GetDefaultStyleClass() → {string}

    Returns the default styleclass for the component. All input components must override.
    Source:
    Returns:
    Type
    string

    <protected> _GetDisplayValue(value) → {string}

    Returns the display value that is ready to be passed to the converter.
    Parameters:
    Name Type Description
    value Object the stored value if available that needs to be formatted for display
    Source:
    Returns:
    usually a string display value
    Type
    string

    <protected> _GetElementValue()

    Returns the element's value. Normally, this is a call to this.element.val(), but for some components, it could be something else. E.g., for ojRadioset the element's value is really the value of the selected radio in the set.
    Source:

    <protected> _GetImplicitValidators() → {Object}

    Returns an array of implicit validators setup by component. This list contains validators for the internal use of the component and are not a part of this.options.validators.
    E.g., if the pattern attribute or option is set, a RegExpValidator instance is automatically created and added to this list.
    RequiredValidator is tracked separately from the default validators.
    Source:
    Returns:
    a map of string name to the validator instance.
    Type
    Object

    <protected> _GetLabelElement() → {Object}

    Returns a jquery object of the element representing the primary label node for the input component. First we look for the aria-labelledby attribute on the input. If that's not found, we look for the label with 'for' attribute pointing to input. If that's not found, we walk up the dom looking for aria-labelledby.
    Source:
    Returns:
    the jquery element that represents the input component's label. return null if it can't find anything.
    Type
    Object

    <protected> _GetMessagingLauncherElement() → {Object}

    Returns a jquery object of the element that triggers messaging behavior. The trigger element is usually an input or select or textarea element for which a value can be set/retrieved and validated.
    Source:
    Returns:
    jquery object
    Type
    Object

    <protected> _GetReadingDirection() → {string}

    Determines whether the component is LTR or RTL.

    Component responsibilities:

    • All components must determine directionality exclusively by calling this protected superclass method. (So that any future updates to the logic can be made in this one place.)
    • Components that need to know the directionality must call this method at create-time and from refresh(), and cache the value.
    • Components should not call this at other times, and should instead use the cached value. (This avoids constant DOM queries, and avoids any future issues with component reparenting (i.e. popups) if support for directional islands is added.)

    App responsibilities:

    • The app specifies directionality by setting the HTML "dir" attribute on the <html> node. When omitted, the default is "ltr". (Per-component directionality / directional islands are not currently supported due to inadequate CSS support.)
    • As with any DOM change, the app must refresh() the component if the directionality changes dynamically. (This provides a hook for component housekeeping, and allows caching.)
    Default Value:
    • "ltr"
    Inherited From:
    Source:
    Returns:
    the reading direction, either "ltr" or "rtl"
    Type
    string

    <protected> _GetSavedAttributes(element) → {Object|null}

    Gets the saved attributes for the provided element.

    If you don't override _SaveAttributes and _RestoreAttributes, then this will return null.

    If you override _SaveAttributes to call _SaveAllAttributes, then this will return all the attributes. If you override _SaveAttributes/_RestoreAttributes to do your own thing, then you may also have to override _GetSavedAttributes to return whatever you saved if you need access to the saved attributes.

    Parameters:
    Name Type Description
    element Object jQuery selection, should be a single entry
    Inherited From:
    Source:
    Returns:
    savedAttributes - attributes that were saved for this element in _SaveAttributes, or null if none were saved.
    Type
    Object | null

    <protected> _HandleChangeEvent(event)

    Convenience handler for the DOM 'change' event. Subclasses are expected to wire up event handlers for DOM events that they wish to handle.
    The implementation retrieves the display value for the component by calling _GetDisplayValue() and calls _SetValue(), with full validation.
    Parameters:
    Name Type Description
    event Event DOM event
    Source:

    <protected> _HasPlaceholderSet()

    whether the placeholder option is set
    Source:

    <protected> _init()

    JET components should almost never implement this JQUI method. Please consult an architect if you believe you have an exception. Reasons:

    • This method is called at create time, after the create event is fired. It is rare for that to be the appropriate time to perform a create-time task. For those rare cases, we have the _AfterCreateEvent method, which is preferred over this method since it is called only at that time, not also at re-init time (see next).
    • This method is also called at "re-init" time, i.e. when the initializer is called after the component has already been created. JET has not yet identified any desired semantics for re-initing a component.
    Inherited From:
    Source:

    <protected> _InitOptions(originalDefaults, constructorOptions)

    Called at component create time primarily to initialize options, often using DOM values. This method is called before _ComponentCreate is called, so components that override this method should be aware that the component has not been rendered yet. The element DOM is available and can be relied on to retrieve any default values.

    This method sets defaults for its options that have a DOM namesake. E.g., value, required, disabled etc. Subclasses can override this method to set their own defaults for these options. Example, the value option is often not set on this.element for components like radioset, which walk the sub-tree to determine the value.

    Parameters:
    Name Type Argument Description
    originalDefaults Object original default options defined on the widget and its ancestors
    constructorOptions Object <nullable>
    options passed into the wiget constructor
    Source:

    <protected> _IsEffectivelyDisabled() → {boolean}

    Determines whether this component is effectively disabled, i.e. it has its 'disabled' attribute set to true or it has been disabled by its ancestor component.

    Inherited From:
    Source:
    Returns:
    true if the component has been effectively disabled, false otherwise
    Type
    boolean

    <protected> _IsRequired() → {boolean}

    Whether the component is required.
    Source:
    Returns:
    true if required; false
    Type
    boolean

    <protected> _NotifyAttached()

    Notifies the component that its subtree has been connected to the document programmatically after the component has been created.

    Inherited From:
    Source:

    <protected> _NotifyContextMenuGesture(menu, event, eventType)

    When the contextMenu option is set, this method is called when the user invokes the context menu via the default gestures: right-click, Press & Hold, and Shift-F10. Components should not call this method directly.

    The default implementation simply calls this._OpenContextMenu(event, eventType). Overrides of this method should call that same method, perhaps with additional params, not menu.open().

    This method may be overridden by components needing to do things like the following:

    • Customize the launcher or position passed to _OpenContextMenu(). See that method for guidance on these customizations.
    • Customize the menu contents. E.g. some components need to enable/disable built-in commands like Cut and Paste, based on state at launch time.
    • Bail out in some cases. E.g. components with UX approval to use PressHoldRelease rather than Press & Hold can override this method to say if (eventType !== "touch") this._OpenContextMenu(event, eventType);. When those components detect the alternate context menu gesture (e.g. PressHoldRelease), that separate listener should call this._OpenContextMenu(), not this method (_NotifyContextMenuGesture()), and not menu.open().

    Components needing to do per-launch setup like the above tasks should do so in an override of this method, not in a beforeOpen listener or an _OpenContextMenu() override. This is discussed more fully here.

    Parameters:
    Name Type Description
    menu Object The JET Menu to open as a context menu. Always non-null.
    event Event What triggered the menu launch. Always non-null.
    eventType string "mouse", "touch", or "keyboard". Never null.
    Inherited From:
    Source:

    <protected> _NotifyDetached()

    Notifies the component that its subtree has been removed from the document programmatically after the component has been created.

    Inherited From:
    Source:

    <protected> _NotifyHidden()

    Notifies the component that its subtree has been made hidden programmatically after the component has been created.

    Inherited From:
    Source:

    <protected> _NotifyShown()

    Notifies the component that its subtree has been made visible programmatically after the component has been created.

    Inherited From:
    Source:

    <protected> _OpenContextMenu(event, eventType, openOptions, submenuOpenOptions, shallow)

    The only correct way for a component to open its context menu is by calling this method, not by calling Menu.open() or _NotifyContextMenuGesture(). This method should be called in two cases:

    • This method is called by _NotifyContextMenuGesture() and its overrides. That method is called when the baseComponent detects the default context menu gestures: right-click, Press & Hold, and Shift-F10.
    • Components with UX-approved support for alternate context menu gestures like PressHoldRelease should call this method directly when those gestures are detected.

    Components needing to customize how the context menu is launched, or do any per-launch setup, should do so in the caller of this method, (which is one of the two callers listed above), often by customizing the params passed to this method (_OpenContextMenu) per the guidance below. This setup should not be done in the following ways:

    • Components should not perform setup in a beforeOpen listener, as this can cause a race condition where behavior depends on who got their listener registered first: the component or the app. The only correct component use of a beforeOpen listener is when there's a need to detect whether something else launched the menu.
    • Components should not override this method (_OpenContextMenu), as this method is final. Instead, customize the params that are passed to it.

    Guidance on setting OpenOptions fields:

    Launcher:

    Depending on individual component needs, any focusable element within the component can be the appropriate launcher for this launch.

    Browser focus returns to the launcher on menu dismissal, so the launcher must at least be focusable. Typically a tabbable (not just focusable) element is safer, since it just focuses something the user could have focused on their own.

    By default (i.e. if openOptions is not passed, or if it lacks a launcher field), the component init node is used as the launcher for this launch. If that is not focusable or is suboptimal for a given component, that component should pass something else. E.g. components with a "roving tabstop" (like Toolbar) should typically choose the current tabstop as their launcher.

    The :focusable and :tabbable selectors may come in handy for choosing a launcher, e.g. something like this.widget().find(".my-class:tabbable").first().

    Position:

    By default, this method applies positioning that differs from Menu's default in the following ways: (The specific settings are subject to change.)

    • For mouse and touch events, the menu is positioned relative to the event, not the launcher.
    • For touch events, "my" is set to "start>40 center", to avoid having the context menu obscured by the user's finger, and "collision" is set to "flipfit", to avoid auto-scrolling on tablets.

    Usually, if position needs to be customized at all, the only thing that needs changing is its "of" field, and only for keyboard launches (since mouse/touch launches should almost certainly keep the default "event" positioning). This situation arises anytime the element relative to which the menu should be positioned for keyboard launches is different than the launcher element (the element to which focus should be returned upon dismissal). For this case, { "position": {"of": eventType==="keyboard" ? someElement : "event"} } can be passed as the openOptions param.

    Be careful not to clobber useful defaults by specifying too much. E.g. if you only want to customize "of", don't pass other fields like "my", since your value will be used for all modalities (mouse, touch, keyboard), replacing the modality-specific defaults that are usually correct. Likewise, don't forget the eventType==="keyboard" check if you only want to customize "of" for keyboard launches.

    InitialFocus:

    This method forces initialFocus to "menu" for this launch, so the caller needn't specify it.

    Parameters:
    Name Type Argument Description
    event Event What triggered the context menu launch. Must be non-null.
    eventType string "mouse", "touch", or "keyboard". Must be non-null. Passed explicitly since caller knows what it's listening for, and since events like contextmenu and click can be generated by various input modalities, making it potentially error-prone for this method to determine how they were generated.
    openOptions Object <optional>
    Options to merge with this method's defaults, which are discussed above. The result will be passed to Menu.open(). May be null or omitted. See also the shallow param.
    submenuOpenOptions Object <optional>
    Options to be passed through to Menu.open(). May be null or omitted.
    shallow boolean <optional>
    Whether to perform a deep or shallow merge of openOptions with this method's default value. The default and most commonly correct / useful value is false.
    • If true, a shallow merge is performed, meaning that the caller's position object, if passed, will completely replace this method's default position object.
    • If false or omitted, a deep merge is performed. For example, if the caller wishes to tweak position.of while keeping this method's defaults for position.my, position.at, etc., it can pass {"of": anOfValue} as the position value.

    The shallow param is n/a for submenuOpenOptions, since this method doesn't apply any defaults to that. (It's a direct pass-through.)

    Inherited From:
    Source:

    <protected> _parseValue(submittedValue) → {Object}

    Parses the value using the converter set and returns the parsed value. If parsing fails the error is written into the element
    Parameters:
    Name Type Argument Description
    submittedValue string <optional>
    to parse
    Source:
    Throws:
    an Object with message
    Type
    Error
    Returns:
    parsed value
    Type
    Object

    <protected> _Refresh(name, value, forceDisplayValueRefresh)

    Called in response to a change in the options set for this component, this method refreshes the component display value. Subclasses can override to provide custom refresh behavior.
    Parameters:
    Name Type Argument Description
    name String <optional>
    the name of the option that was changed
    value Object <optional>
    the current value of the option
    forceDisplayValueRefresh boolean <optional>
    Source:

    <protected> _RefreshAriaRequired(value)

    Called when a aria-required attribute needs to be set or removed. Most inputs/selects need aria-required on the input element (aka 'content') But it is not legal to have aria-required on radio/checkboxes. Subclasses can override to put aria-required where they want.
    Parameters:
    Name Type Argument Description
    value Object <optional>
    the current value of the required option
    Source:

    <protected> _ResetAllValidators()

    EditableValue caches the validators to be run, within this._allValidators variable. This is great; however when the implicit validator needs to be reset [i.e. min + max changing] or the validators option changes, then the cached this._allValidators needs to be cleared. This method also updates the messaging strategies as hints associated with validators could have changed.
    Source:

    <protected> _ResetComponentState()

    Called anytime the label DOM changes requiring a reset of any dependent feature that caches the label, including all validators.
    Source:

    <protected> _ResetConverter()

    Clears the cached converter stored in _converter and pushes new converter hint to messaging. Called when convterer option changes
    Source:

    <protected> _RestoreAllAttributes()

    Restores all the element's attributes which were saved in _SaveAllAttributes. This method is final in JET.

    If a subclass wants to save/restore all attributes on create/destroy, then the subclass can override _SaveAttributes and call _SaveAllAttributes and also override _RestoreAttributes and call _RestoreAllAttributes.

    Inherited From:
    Source:

    <protected> _RestoreAttributes()

    Source:

    <protected> _SaveAllAttributes(element)

    Saves all the element's attributes within an internal variable. _RestoreAllAttributes will restore the attributes from this internal variable.

    This method is final in JET. Subclasses can override _RestoreAttributes and call _RestoreAllAttributes.

    The JSON variable will be held as:

    [
      {
      "element" : element[i],
      "attributes" :
        {
          attributes[m]["name"] : {"attr": attributes[m]["value"], "prop": $(element[i]).prop(attributes[m]["name"])
        }
      }
    ]
    
    Parameters:
    Name Type Description
    element Object jQuery selection to save attributes for
    Inherited From:
    Source:

    <protected> _SaveAttributes(element)

    Saves all the element's attributes. In _destroy all attributes will be restored.

    Parameters:
    Name Type Description
    element Object jQuery selection to save attributes for
    Source:

    <protected> _SetDisabledDom(node)

    Sets the disabled option onto the dom. Component subclasses can override this method to not do this in cases where it is invalid, like on a div (e.g., radioset's root dom element is a div).
    Parameters:
    Name Type Description
    node Object dom node
    Since:
    • 1.0.0
    Source:

    <protected> _SetDisplayValue(displayValue)

    Called when the display value on the element needs to be updated. This method updates the (content) element value. Widgets can override this method to update the element appropriately.
    Parameters:
    Name Type Description
    displayValue String of the new string to be displayed
    Source:

    <protected> _setOption(name, value, flags)

    Called (by the widget factory) when the option changes, this method responds to the change by refreshing the component if needed. This method is not called for the options passed in during the creation of the widget.
    Parameters:
    Name Type Description
    name string of the option
    value Object | string
    flags Object? optional flags. The following flags are currently supported:
    • changed - true if the caller wants to indicate the value has changed, so no comparison is necessary
    Source:

    <protected> _SetPlaceholder(value)

    Sets the placeholder text on the content element by default. It sets the placeholder attribute on the element. Component subclasses can override this method to control where placeholder text gets set.
    Parameters:
    Name Type Description
    value string
    Source:

    <protected> _SetPlaceholderOption(value)

    Sets the placeholder option with the value.
    Parameters:
    Name Type Description
    value string
    Source:

    <protected> _SetRawValue(event, val)

    Convenience function to set the rawValue option. Called by subclasses
    Parameters:
    Name Type Argument Description
    event Event DOM event
    val String <optional>
    value to set rawValue to
    Source:

    <protected> _SetRootAttributes()

    Reads the rootAttributes option, and sets the root attributes on the component's root DOM element. See rootAttributes for the set of supported attributes and how they are handled.

    Inherited From:
    Source:
    Throws:
    if unsupported attributes are supplied.

    <protected> _SetValue(newValue, event, options) → {boolean}

    Runs full validation on the newValue (usually the display value) and sets the parsed value on the component if value passes basic checks and there are no validation errors.
    If the newValue is undefined or if it differs from the last saved displayValue this method skips validation and does not set value (same as ADF).
    Parameters:
    Name Type Argument Description
    newValue string | Object the ui value that needs to be parsed before it's set.
    event Object <optional>
    an optional event if this was a result of ui interaction. For user initiated actions that trigger a DOM event, passing this event is required. E.g., if user action causes a 'blur' event.
    options Object <optional>
    an Object literal that callers pass in to determine how validation gets run.
    Properties
    Name Type Argument Description
    doValueChangeCheck boolean <optional>
    if set to true compare newValue with last displayValue before running validation; if false, always run validation. E.g., set to false when validate() is called.
    doNotClearMessages boolean <optional>
    if set method will not clear all messages. This is provided for callers that may want to clear only some of the messages. E.g., when required option changes, it clears only component messages, not custom.
    validationMode number <optional>
    accepted values (defined in _VALIDATION_MODE) are:
    • FULL - the default and runs both the converter and all validators.
    • VALIDATORS_ONLY - runs all validators including the required validator is run.
    • REQUIRED_VALIDATOR_ONLY - runs just the required validator.
    Source:
    Returns:
    false if value was not set due to validation error.
    Type
    boolean
    Example

    Widget subclasses can use this convention to run full validation

    this._SetValue(value, event);

    <protected> _UnregisterChildNode()

    Remove all listener references that were attached to the element which includes _activeable, _focusable and hoverable.
    Inherited From:
    Source:

    <protected> _Validate(newValue, event, options) → {Object|string|undefined}

    Runs full validation on the value. If value fails basic checks (see _CanSetValue, or if value failed validation, this method returns false. Otherwise it returns true.

    Components should call this method if they know UI value has changed and want to set the new component value.

    Parameters:
    Name Type Argument Description
    newValue string | Object the actual value to be set. Usually this is the string display value
    event Object <optional>
    an optional event if this was a result of ui interaction. For user initiated actions that trigger a DOM event, passing this event is required. E.g., if user action causes a 'blur' event.
    options {doNotClearMessages:boolean,validationContext:number,validationMode:number} <optional>
    an Object literal that callers pass in to determine how validation gets run.
    Properties
    Name Type Argument Description
    doNotClearMessages boolean <optional>
    if set method will not clear all messages. This is provided for callers that may want to clear only some of the messages. E.g., when required option changes, it clears only component messages, not custom.
    validationContext number <optional>
    the context this method was called. When not set it defaults to _VALIDATION_CONTEXT.USER_ACTION.
    validationMode number <optional>
    accepted values defined in _VALIDATION_MODE
    Source:
    Returns:
    the parsed value or undefined if validation failed
    Type
    Object | string | undefined

    <protected> Focus() → {*}

    Sets focus on the element that naturally gets focus. For example, this would be the input element for input type components.
    Since:
    • 0.7
    Source:
    Returns:
    a truthy value if focus was set to the intended element, a falsey value otherwise.
    Type
    *