Class: EditableValueUtils

Oracle® JavaScript Extension Toolkit (JET)
1.2.0

E65435-01

QuickNav

oj. EditableValueUtils

Version:
  • 1.2.0
Since:
  • 0.6
JET Editable Component Utils

Constructor

new EditableValueUtils()

Source:

Methods

<static> coerceDomValueForOption(option, domValue)

Coerces the dom value being used for the option, and throws error if invalid.
Parameters:
Name Type Description
option string name of the option.
domValue string | Object | boolean | number | null dom value that is being coerced to the option value
Source:
Throws:
if domValue cannot be coerced appropriately
Type
Error

<static> initializeOptionsFromDom(props, constructorOptions, comp, postprocessCallback)

Called from component._InitOptions(), when a component might need to initialize its options from DOM. This usually is done when the constructor option is undefined, even in the case where this.options.option has a value that comes from app defaults or component (original) default. See below for details.

IMPORTANT: Do not call this method after component has been created, since option values are mutated directly after that point.

The 'final' value an option uses/initializes from, can come from these places (in order of least to most likely) -
  1. component default - this is the widget default

  2. app default - this is what a page author defines for the value in the page/app

  3. dom value - if your option also has a dom attribute, this is the value set on element for component.

  4. constructor value - this is the value page author sets on the component binding

At the time _InitOptions is called, (1), (2) and (4) are merged, but this may not be the value a component wants for the option, especially when (4) is undefined. For example, if these values were set for a component -
(1) - 'foo'
(2) - 'bar'
(3) - 'lucy'
(4) - undefined

at the time _InitOptions is called, this.options.option is set to 'bar', but because DOM value wins over app default or component default, component needs to check if the constructor value was undefined and if so, set option to 'lucy'.
If the dom value is not set, then the component provided default value - defaultOptionValue gets used. This method always defaults the value to be - this.options.option || defaultOptionValue - because we think if neither (3) nor (4) is set, then the value from (2) should win over the defaultOptionValue.

Parameters:
Name Type Argument Description
props Object an Object literal that a component provides with the following properties that helps determine the final value for one or more options.
constructorOptions Object the options set on the component instance, often using component binding.
comp Object component instance.
postprocessCallback Function <optional>
optional callback that will receive a map of initialized options for post-processing
Properties:
Name Type Description
props.attribute string name of DOM attribute
props.option string | undefined name of the option if different from attribute name.
props.defaultOptionValue Object | null | string | number | boolean the default value to use for the option when the DOM value is not set. For example, editable components bound to inputs, would pass false as the default for disabled option, while components like the *set components would pass null, because they support a tri-state.
props.coerceDomValue Function | boolean | undefined if the DOM value is set and coercing the dom value is needed, then either set to boolean true, which uses the default coercion rules for common attributes (a), or provide a custom callback (b).

E.g., 'value' option for input number, input date etc. have special rules for coercing the value, so thse provide a custom callback. For common attributes like required and disabled, set the value to true so the default oj.EditableValueUtils#coerceDomValueForOption method gets used.

props.validateOption boolean | undefined if set to true, then it calls oj.EditableValueUtils.validateValueForOption method to validate the option.
Source:

<static> validateValueForOption(option, value)

Validates value set for the option and throws error if invalid.
Parameters:
Name Type Description
option string name of the option. Validates options common to all edtiableValue holders.
value string | Object | boolean | number | undefined of the option that is validated
Source:
Throws:
if option value is invalid
Type
Error