Usage
Signature:
interface MessagesElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { MessagesElement } from "ojs/ojmessages";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojmessages";
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.
Styling Classes
-
.oj-messages-inline-remove-bottom-border
-
Inline messages will include a bottom border so that the messages section is demarcated from the contents below it. If this border is not desirable for certain page layouts, it can be removed by setting this marker class on oj-messages.
Example
<oj-messages class="oj-messages-inline-remove-bottom-border"> <!-- Content --> </oj-messages>
-
.oj-messages-outlined
-
Inline messages (Banners) can be either Edge-to-Edge or Outlined. By default, the inline messages are rendered as Edge-to-Edge Banner messages. If Outlined Banner messages are preferred instead, add oj-messages-outlined class on the oj-messages element.
- Since:
- 10.0.0
Example
<oj-messages class="oj-messages-outlined"> <!-- Content --> </oj-messages>
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-messages>
element accepts only<oj-message>
element as children for the default slot. The default slot contents are rendered only if the 'messages' attribute on<oj-messages>
is not set. If the 'messages' attribute is set<oj-message>
children are automatically stamped for each message data in the collection.Note that the use of inlined oj-message children inside of oj-messages is deprecated. Applications should directly databind 'messages' attribute of oj-messages instead. Using oj-message inside of the 'messageTemplate' slot to define the template is still valid.
- Since:
- 5.0.0
-
messageTemplate
-
The
messageTemplate
slot is used to specify the template for rendering each message in theoj-messages
. The slot must be a <template> element. The default template will display theoj-message
children to best suit the display type of theoj-messages
. This template slot will be applied only if the 'messages' attribute onoj-messages
> is set. The content of the template must be anoj-message
element.When the template is executed for each message, it will have access to the binding context containing the following properties:
- $current - an object that contains information for the current message. (See oj.ojMessages.MessageTemplateContext or the table below for a list of properties available on $current)
- alias - if 'data-oj-as' attribute was specified on the <template> element, the value will be used to provide an application-named alias for $current.
- Since:
- 6.2.0
Properties of $current:
Name Type Description componentElement
Element The <oj-messages> custom element. data
oj.ojMessage.Message The data for the current message being rendered.
Attributes
-
display :"general"|"notification"
-
Specifies the display purpose of messages. The valid values for display are
The presentation of the message is inline by default. However, when a oj.ojMessages#positionproperty is provided, the presentation will be an overlay. The alignment of the overlay will default based on thegeneral
andnotification
. General messages are commonly rendered at the page level or section level, relating to the task the user performed. Notification messages are typically used for reporting asynchronous events, or to communicate some background activity.display
property. The defaults are defined by the theme.- Default Value:
"general"
- Since:
- 5.0.0
Supported Values:
Value Description general
Messages pertaining to the page or region of the application. notification
Often used for communicating alerts arriving asynchronously. Names
Item Name Property display
Property change event displayChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-display-changed
-
display-options :oj.ojMessage.DisplayOptions
-
Specifies the display options for contents of all the messages specified for the oj.ojMessages#messages attribute.
- Since:
- 6.1.0
Names
Item Name Property displayOptions
Property change event displayOptionsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-display-options-changed
-
display-options.category :"header"|"auto"|"none"
-
Specifies display option for oj.ojMessage#message.category text in all the messages specified for the oj.ojMessages#messages attribute.
In Redwood theme, showing the category text is an anti-pattern. Set this attribute to "none".
- Default Value:
"auto"
Supported Values:
Value Description auto
The component decides whether and where the oj.ojMessage#message.category text is displayed. The behavior is same as 'header' option, but may change in future releases. header
If the oj.ojMessage#message.category property is specified, its value will be displayed in the header region of the message next to message icon. If oj.ojMessage#message.category property is not specified, a translated text corresponding to the value of the oj.ojMessage#message.severity property will be displayed. none
The oj.ojMessage#message.category text will not be displayed. Names
Item Name Property displayOptions.category
-
messages :(Array.<oj.ojMessage.Message>|null|DataProvider.<any, oj.ojMessage.Message>)
-
Specifies the collection of structured message data used to display the individual messages. This property can be used to conveniently specify the required data as a single collection. Individual message will be automatically created based on this data. See oj.ojMessage.Message for message values.
More information about the structured 'Message' data can be found in documentation for 'message' attribute of
The collection can be two types:oj-message
element.- an array of oj.ojMessage.Message objects.
- oj.ArrayDataProvider of oj.ojMessage.Message objects. Look at ArrayDataProvider for more available options.
- Default Value:
null
- Since:
- 5.0.0
Names
Item Name Property messages
Property change event messagesChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-messages-changed
-
position :(oj.ojMessages.Position|null)
-
The position property defines the presentation style. The default presentation is inline, defined by a
Default position sub-properites are extended by the provided value. Defaults vary based on thenull
position property value. When a value is provide for the property, the presentation style will be an overaly "popup". The alignment of the overaly is defined by the position sub-properties.display
property and provided by theme. The position property is used to establish the location where the messages popup overlay will appear relative to another element.The "my" and "at" properties defines alignment points relative to the popup and other element. The "my" property represents the popups alignment where the "at" property represents the other element that can be identified by "of" or defauts to the launcher when the popup opens. The values of these properties describe horizontal and vertical alignments.
Names
Item Name Property position
Property change event positionChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-position-changed
-
position.at :Object
-
Defines which position on the target element ("of") to align the positioned element against.
Names
Item Name Property position.at
-
position.at.horizontal :"start"|"end"|"left"|"center"|"right"
-
Defines the horizontal alignment of what the messages overlay is aligned to.
Supported Values:
Value Description center
end
Evaluates to "right" in LTR mode and "left" in RTL mode. left
right
start
Evaluates to "left" in LTR mode and "right" in RTL mode. Names
Item Name Property position.at.horizontal
-
position.at.vertical :"top"|"center"|"bottom"
-
Defines the vertical alignment of what the messages overlay is aligned to.
Supported Values:
Value bottom
center
top
Names
Item Name Property position.at.vertical
-
position.collision :"flip"|"fit"|"flipfit"|"none"
-
Rule for alternate alignment.
Supported Values:
Value Description fit
Shift the element away from the edge of the window. flip
The element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used. flipfit
First applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible. none
No collision detection. Names
Item Name Property position.collision
-
position.my :Object
-
Defines which edge on the messages overlay to align with the target ("of") element.
Names
Item Name Property position.my
-
position.my.horizontal :"start"|"end"|"left"|"center"|"right"
-
Defines the horizontal alignment of the messages overlay.
Supported Values:
Value Description center
end
Evaluates to "right" in LTR mode and "left" in RTL mode. left
right
start
Evaluates to "left" in LTR mode and "right" in RTL mode. Names
Item Name Property position.my.horizontal
-
position.my.vertical :"top"|"center"|"bottom"
-
Defines the vertical alignment of the messages overlay.
Supported Values:
Value bottom
center
top
Names
Item Name Property position.my.vertical
-
position.of :string
-
Which element to position the messages overlay against. If the value is a string, it should be a selector or the literal string value of
window
. Otherwise, a point of x,y. When a point is used, the values are relative to the whole document. Page horizontal and vertical scroll offsets need to be factored into this point - see UIEvent pageX, pageY.Names
Item Name Property position.of
-
position.offset :Object
-
Defines a point offset in pixels from the ("my") alignment.
Names
Item Name Property position.offset
-
position.offset.x :number
-
Horizontal alignment offset.
Names
Item Name Property position.offset.x
-
position.offset.y :number
-
Vertical alignment offset.
Names
Item Name Property position.offset.y
-
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.
- Since:
- 5.0.0
Names
Item Name Property translations
Property change event translationsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-translations-changed
-
(nullable) translations.aria-live-region :Object
-
Various contextual live region texts that oj-messages component will use for accessibility purpose.
See the translations attribute for usage examples.
- Since:
- 5.0
Names
Item Name Property translations.ariaLiveRegion
-
(nullable) translations.aria-live-region.navigation-from-keyboard :string
-
Text to guide keyboard users navigate to prior focussed element when the messages region gains focus.
See the translations attribute for usage examples.
- Default Value:
"Entering messages region. Press F6 to navigate back to prior focused element."
- Since:
- 5.0
Names
Item Name Property translations.ariaLiveRegion.navigationFromKeyboard
-
(nullable) translations.aria-live-region.navigation-to-keyboard :string
-
Text to guide keyboard users navigate to new displayed messages when focus is outside the messages popup.
See the translations attribute for usage examples.
- Default Value:
"Messages region has new messages. Press F6 to navigate to the most recent message region."
- Since:
- 5.0
Names
Item Name Property translations.ariaLiveRegion.navigationToKeyboard
-
(nullable) translations.aria-live-region.navigation-to-touch :string
-
Text to guide touch screen (voice-over) users navigate to new displayed messages when focus is outside the messages popup.
See the translations attribute for usage examples.
- Default Value:
"Messages region has new messages. Use the voice-over rotor to navigate to the messages landmark."
- Since:
- 5.0
Names
Item Name Property translations.ariaLiveRegion.navigationToTouch
-
(nullable) translations.aria-live-region.new-message :string
-
Text representing the new displayed message. This text may contain tokens '{category}' ,'{summary}' and '{detail}', which will be replaced by the corresponding sub-property values in the data for the new message.
See the translations attribute for usage examples.
- Default Value:
"Message category {category}. {summary}. {detail}."
- Since:
- 5.0
Names
Item Name Property translations.ariaLiveRegion.newMessage
-
(nullable) translations.aria-live-region.no-detail :string
-
Text to be used in the live region when there is no detail.
See the translations attribute for usage examples.
- Default Value:
"Detail is not available"
- Since:
- 14.1.0
Names
Item Name Property translations.ariaLiveRegion.noDetail
-
(nullable) translations.label-landmark :string
-
Label for the landmark region for accessibility.
See the translations attribute for usage examples.
- Default Value:
"Messages"
- Since:
- 5.0
Names
Item Name Property translations.labelLandmark
Methods
-
close(message) : {void}
-
Closes the specified message regardless of the oj.ojMessage#message.autoTimeout or oj.ojMessage#message.closeAffordance properties. The
message
argument is a required argument, must be of type oj.ojMessage#message, and must be the same object instance that was used to create and show the oj-message.Closing a message changes the visibility to hidden. If the message is defined by an instance in the oj.ojMessages#messages collection, the close operation will not remove the item from the backing model. Application logic needs to listen for the oj.ojMessage#event:close event bubbling up from the underlying oj-message child to remove from the backing collection.
Parameters:
Name Type Description message
oj.ojMessage.Message The message to be closed. - Since:
- 5.0.0
Returns:
- Type
- void
-
closeAll(closeFilter) : {void}
-
Closes child messages matching the
closeFilter
callback criteria. ThecloseFilter
callback is an optional argument. If not specified, all child messages will be closed. If filter is specified, object of type oj.ojMessage#message corresponding to each child will be passed to thecloseFilter
function. A return value oftrue
will result in calling oj.ojMessage#close for the message. Otherwise, the message will remain in its current state.Closing a message changes the visibility to hidden. If the message is defined by an instance in the oj.ojMessages#messages collection, the close operation will not remove the item from the backing model. Application logic needs to listen for the oj.ojMessage#event:close event bubbling up from the underlying oj-message child to remove from the backing collection.
Parameters:
Name Type Argument Description closeFilter
(message: ojMessage.Message) => boolean <optional>
An optional callback function that will be passed an instance of type oj.ojMessage#message for each child oj-message. If closeFilter
returnstrue
, the associated oj-message will be closed. Returningfalse
will exclude the child message from closure. If acloseFilter
is not passed, all child messages will be closed.- Since:
- 5.0.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. - Since:
- 5.0.0
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. - Since:
- 5.0.0
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. - Since:
- 5.0.0
Returns:
- Type
- void
Type Definitions
-
MessageTemplateContext
-
Properties:
Name Type Description componentElement
Element The <oj-messages> custom element. data
oj.ojMessage.Message The data for the current message being rendered. -
Position
-
- "flip" the element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used.
- "fit" shift the element away from the edge of the window.
- "flipfit" first applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible.
- "none" no collision detection.
Properties:
Name Type Argument Description at
oj.ojMessages.PositionAlign <optional>
Defines which position on the target element ("of") to align the positioned element against. collision
"flip" | "fit" | "flipfit" | "none" <optional>
Rule for alternate alignment. my
oj.ojMessages.PositionAlign <optional>
Defines which edge on the popup to align with the target ("of") element. of
string | oj.ojMessages.PositionPoint <optional>
Which element to position the popup against. If the value is a string, it should be a selector or the literal string value of window
. Otherwise, a point of x,y. When a point is used, the values are relative to the whole document. Page horizontal and vertical scroll offsets need to be factored into this point - see UIEvent pageX, pageY.offset
oj.ojMessages.PositionPoint <optional>
Defines a point offset in pixels from the ("my") alignment. -
PositionAlign
-
- "start" evaluates to "left" in LTR mode and "right" in RTL mode.
- "end" evaluates to "right" in LTR mode and "left" in RTL mode.
Properties:
Name Type Argument Description horizontal
"start" | "end" | "left" | "center" | "right" <optional>
Horizontal alignment. vertical
"top" | "bottom" | "center" <optional>
Vertical alignment. -
PositionPoint
-
Properties:
Name Type Argument Description x
number <optional>
Horizontal alignment offset. y
number <optional>
Vertical alignment offset.