Usage
Signature:
interface ValidationGroupElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { ValidationGroupElement } from "ojs/ojvalidationgroup";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojvalidationgroup";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
Default
-
The
<oj-validation-group>
accepts any DOM elements in its Default slot but only tracks the validity state of any JET custom element descendents that contain the valid property.- Since:
- 4.2.0
Attributes
-
(readonly) valid :"valid"|"pending"|"invalidHidden"|"invalidShown"
-
The current validity state of the
oj-validation-group
element.The oj-validation-group's
valid
property value is calculated from all the enabled components it tracks. The most 'invalid' component'svalid
property value will be oj-validation-group'svalid
property value. For example, if all the components are valid except one is "invalidShown", then oj-validation-group's valid value will be "invalidShown". If one is "invalidShown" and one is "invalidHidden", then oj-validation-group's valid value will be "invalidShown" since "invalidShown" is more invalid than "invalidHidden".When any of the enabled tracked component's valid value changes, oj-validation-group will be notified and will update its own valid value if it has changed. There is no default value for the valid property since it is a read-only property that is calculated on initialization and kept updated if any of its tracked component's valid value changes.
The oj-validation-group does not filter out components that are hidden. Hidden components will be considered in oj-validation-group's valid calculation as long as they are enabled. A hidden enabled component's valid state is no different than a visible enabled component; if there is an error that isn't a deferred error, its valid value is "invalidShown". You can disable any components you do not want considered in oj-validation-group's valid value.
Note: New valid states may be added to the list of valid values in future releases. If so, we will keep the convention where if it is valid, it will start with "valid". If it is invalid, it will start with "invalid". If it is pending, it will start with "pending".
- Supports writeback:
true
- Since:
- 4.2
Supported Values:
Value Description invalidHidden
The component has invalid messages hidden and no invalid messages showing. An invalid message is one with severity "error" or higher. invalidShown
The component has invalid messages showing. An invalid message is one with severity "error" or higher. pending
The component is waiting for the validation state to be determined. valid
The component is valid Names
Item Name Property valid
Property change event validChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-valid-changed
Methods
-
focusOn(key) : {void}
-
If the parameter passed in is "@firstInvalidShown", then it sets focus on the first enabled component with invalid messages showing, if any. If nothing is passed in, it will set focus to the first enabled component being tracked, if any. An enabled component is one that is not disabled or readonly.
Parameters:
Name Type Argument Description key
'@firstInvalidShown' <optional>
"@firstInvalidShown" will focus on first invalidShown enabled component in DOM order, if any. When no parameter is passed in, the method will focus on first enabled component regardless of the valid state, if any. An enabled component is one that is not disabled or readonly. - Since:
- 4.2.0
Returns:
- Type
- void
-
getProperty(property) : {any}
-
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
- any
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description properties
Object An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description property
string The property name to set. Supports dot notation for subproperty access. value
any The new value to set the property to. Returns:
- Type
- void
-
showMessages : {void}
-
Takes all deferred messages and shows them on each enabled component. An enabled component is one that is not disabled or readonly. As a result, the valid property may be updated; 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:
- 4.2.0
Returns:
- Type
- void