Class MessageList
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasSize,HasStyle,HasTheme,HasThemeVariant<MessageListVariant>,LocaleChangeObserver,Serializable
setItems(Collection).- Since:
- 14.7
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEvent fired when an attachment is clicked in the message list. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new message list component.MessageList(MessageListItem... items) Creates a new message list component, with the provided items rendered as messages.MessageList(Signal<List<S>> itemsSignal) Creates a new message list component with the provided signal bound to the items.MessageList(Collection<MessageListItem> items) Creates a new message list component, with the provided items rendered as messages. -
Method Summary
Modifier and TypeMethodDescriptionAdds a listener that is called when an attachment is clicked.voidaddItem(MessageListItem item) Adds a single item to be rendered as a message at the end of this message list.<S extends Signal<MessageListItem>>
SignalBinding<List<S>> Binds the given signal to the items of the message list as a one-way binding so that the rendered messages are updated when the signal's value or any individual item signal changes.<S extends Signal<MessageListUser>>
SignalBinding<List<MessageListUser>> bindTypingUsers(Signal<List<S>> typingUsersSignal) Binds the given signal to the users that are currently typing as a one-way binding so that the typing indicator is updated when the signal's value or any individual user signal changes.getI18n()Gets the internationalization object previously set for this component.getItems()Gets the items that are rendered as message components in this message list.Gets the style in which the typing indicator is rendered.Gets the users that are currently typing.booleanReturns whether new messages are announced to assistive technologies.booleanReturns whether the messages are parsed as markdown.voidlocaleChange(LocaleChangeEvent event) Notifies when the UI locale is changed.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.voidsetAnnounceMessages(boolean announceMessages) When set totrue, new messages are announced to assistive technologies using ARIA live regions.voidsetI18n(MessageListI18n i18n) Sets the internationalization object for this component.voidsetItems(MessageListItem... items) Sets the items that will be rendered as messages in this message list.voidsetItems(Collection<MessageListItem> items) Sets the items that will be rendered as messages in this message list.voidsetMarkdown(boolean markdown) Sets whether the messages should be parsed as markdown.voidsetTypingIndicatorType(MessageListTypingIndicatorType typingIndicatorType) Sets the style in which the typing indicator is rendered.voidsetTypingUsers(MessageListUser... typingUsers) Sets the users that are currently typing.voidsetTypingUsers(List<MessageListUser> typingUsers) Sets the users that are currently typing.Methods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
-
Constructor Details
-
MessageList
public MessageList()Creates a new message list component. To populate the content of the list, usesetItems(Collection). -
MessageList
Creates a new message list component, with the provided items rendered as messages.- Parameters:
items- the items to render as messages- See Also:
-
MessageList
Creates a new message list component, with the provided items rendered as messages.- Parameters:
items- the items to render as messages- See Also:
-
MessageList
Creates a new message list component with the provided signal bound to the items.The rendered messages are updated when the signal's value or any individual item signal changes. Any signal change results in a full update.
- Type Parameters:
S- the type of signal holding individual items- Parameters:
itemsSignal- the signal to bind the items to, notnull- Since:
- 25.2
- See Also:
-
-
Method Details
-
setItems
Sets the items that will be rendered as messages in this message list.- Parameters:
items- the items to set, notnulland not containing anynullitems
-
setItems
Sets the items that will be rendered as messages in this message list.- Parameters:
items- the items to set, none of which can benull
-
addItem
Adds a single item to be rendered as a message at the end of this message list.- Parameters:
item- the item to add, notnull- Since:
- 24.8
-
getItems
Gets the items that are rendered as message components in this message list.- Returns:
- an unmodifiable view of the list of items
-
bindItems
public <S extends Signal<MessageListItem>> SignalBinding<List<S>> bindItems(Signal<List<S>> itemsSignal) Binds the given signal to the items of the message list as a one-way binding so that the rendered messages are updated when the signal's value or any individual item signal changes. Any signal change results in a full update.When a signal is bound, the items are kept synchronized with the signal value while the component is attached. When the component is detached, signal value changes have no effect.
While a signal is bound, any attempt to modify items manually through
setItems(Collection)oraddItem(MessageListItem)throws aBindingActiveException.- Type Parameters:
S- the type of signal holding individual items- Parameters:
itemsSignal- the signal to bind the items to, notnull- Since:
- 25.2
-
localeChange
Description copied from interface:LocaleChangeObserverNotifies when the UI locale is changed.- Specified by:
localeChangein interfaceLocaleChangeObserver- Parameters:
event- locale change event with event details
-
setMarkdown
public void setMarkdown(boolean markdown) Sets whether the messages should be parsed as markdown. By default, this is set tofalse.- Parameters:
markdown-trueif the message text is parsed as Markdown.- Since:
- 24.8
-
isMarkdown
public boolean isMarkdown()Returns whether the messages are parsed as markdown.- Returns:
trueif the message text is parsed as Markdown.- Since:
- 24.8
-
setAnnounceMessages
public void setAnnounceMessages(boolean announceMessages) When set totrue, new messages are announced to assistive technologies using ARIA live regions. By default, this is set tofalse.- Parameters:
announceMessages-trueif new messages should be announced to assistive technologies.- Since:
- 24.8
-
isAnnounceMessages
public boolean isAnnounceMessages()Returns whether new messages are announced to assistive technologies.- Returns:
trueif new messages are announced to assistive technologies.- Since:
- 24.8
-
getTypingUsers
Gets the users that are currently typing.This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Returns:
- an unmodifiable view of the users that are currently typing, empty by default
- Since:
- 25.3
-
setTypingUsers
Sets the users that are currently typing. A typing indicator with the names and avatars of these users is rendered at the end of the message list. Pass an empty list to hide the typing indicator.The message list does not remove the users on its own. It is up to the application to clear them once the users have stopped typing.
This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Parameters:
typingUsers- the users that are currently typing, notnulland not containing anynullusers- Since:
- 25.3
-
setTypingUsers
Sets the users that are currently typing. A typing indicator with the names and avatars of these users is rendered at the end of the message list. Pass no users to hide the typing indicator.The message list does not remove the users on its own. It is up to the application to clear them once the users have stopped typing.
This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Parameters:
typingUsers- the users that are currently typing, none of which can benull- Since:
- 25.3
-
bindTypingUsers
public <S extends Signal<MessageListUser>> SignalBinding<List<MessageListUser>> bindTypingUsers(Signal<List<S>> typingUsersSignal) Binds the given signal to the users that are currently typing as a one-way binding so that the typing indicator is updated when the signal's value or any individual user signal changes.When a signal is bound, the typing users are kept synchronized with the signal value while the component is attached. When the component is detached, signal value changes have no effect.
While a signal is bound, any attempt to modify the typing users manually through
setTypingUsers(List)throws aBindingActiveException.This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Type Parameters:
S- the type of signal holding individual users- Parameters:
typingUsersSignal- the signal to bind the typing users to, notnull- Returns:
- a
SignalBindingthat can be used to registeronChangecallbacks - Since:
- 25.3
-
getTypingIndicatorType
Gets the style in which the typing indicator is rendered.This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Returns:
- the typing indicator type,
MessageListTypingIndicatorType.DEFAULTby default - Since:
- 25.3
-
setTypingIndicatorType
Sets the style in which the typing indicator is rendered. The style is applied right away, also when the typing indicator is currently displayed. By default, the typing indicator is rendered in theMessageListTypingIndicatorType.DEFAULTstyle.This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Parameters:
typingIndicatorType- the typing indicator type, notnull- Since:
- 25.3
-
getI18n
Gets the internationalization object previously set for this component.Note: updating the object properties after getting the i18n object does not update the component. Set the object again with
setI18n(MessageListI18n)to apply the changes.This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Returns:
- the i18n object, or
nullif no i18n object has been set - Since:
- 25.3
-
setI18n
Sets the internationalization object for this component. The texts are applied right away, also when the typing indicator is currently displayed.Note: updating the object properties after setting the i18n object does not update the component. Set the object again to apply the changes.
This API is experimental and needs to be enabled with the
com.vaadin.experimental.messageListTypingIndicatororcom.vaadin.experimental.aiComponentsfeature flag.- Parameters:
i18n- the i18n object, notnull- Since:
- 25.3
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
AttachEventis fired for the component. Make sure to callsuper.onAttachwhen overriding this method. -
addAttachmentClickListener
public Registration addAttachmentClickListener(ComponentEventListener<MessageList.AttachmentClickEvent> listener) Adds a listener that is called when an attachment is clicked.- Parameters:
listener- the listener to add- Returns:
- a registration that can be used to remove the listener
- Since:
- 25.1
-