Class CollaborationMessageList
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasSize,HasStyle,Serializable
MessageList component which integrates with the
CollaborationEngine. It reads the messages from a topic and renders
them within the component. The list is automatically updated when new
messages are available. You can use the CollaborationMessageInput
component for submitting messages.- Since:
- 3.1
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceConfigurator callback for messages in aCollaborationMessageList. -
Constructor Summary
ConstructorsConstructorDescriptionCollaborationMessageList(UserInfo localUser, String topicId) Creates a new collaboration message list component with the provided topic id.CollaborationMessageList(UserInfo localUser, String topicId, CollaborationMessagePersister persister) Creates a new collaboration message list component with the provided topic id and persister ofCollaborationMessageitems from/to an external source (e.g. -
Method Summary
Modifier and TypeMethodDescriptionGets the currently used image handler callback.Deprecated, for removal: This API element is subject to removal in a future version.Gets the current message configurator, if any.booleanWrapper method forMessageList.isAnnounceMessages().booleanWrapper method forMessageList.isMarkdown().voidsetAnnounceMessages(boolean announceMessages) Wrapper method forMessageList.setAnnounceMessages(boolean).voidsetImageHandler(CollaborationAvatarGroup.ImageHandler imageHandler) Sets an image handler callback for dynamically loading avatar images for a given user.voidsetImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider) Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.voidsetMarkdown(boolean markdown) Wrapper method forMessageList.setMarkdown(boolean).voidsetMessageConfigurator(CollaborationMessageList.MessageConfigurator messageConfigurator) Sets a configurator callback for the messages.voidsetSubmitter(CollaborationMessageSubmitter submitter) Sets a submitter to handle the append of messages to the list.voidSets the topic to use with this component.Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods 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
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, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
CollaborationMessageList
Creates a new collaboration message list component with the provided topic id.It renders messages received by a
CollaborationMessageInputor a custom submitter component connected to this list viasetSubmitter(CollaborationMessageSubmitter)If a
nulltopic id is provided, the component won't display any messages, until connecting to a non-null topic withsetTopic(String).- Parameters:
localUser- the information of the end user, notnulltopicId- the id of the topic to connect to, ornullto not connect the component to any topic
-
CollaborationMessageList
public CollaborationMessageList(UserInfo localUser, String topicId, CollaborationMessagePersister persister) Creates a new collaboration message list component with the provided topic id and persister ofCollaborationMessageitems from/to an external source (e.g. a database).It renders messages received by a
CollaborationMessageInputor a custom submitter component connected to this list viasetSubmitter(CollaborationMessageSubmitter)If a
nulltopic id is provided, the component won't display any messages, until connecting to a non-null topic withsetTopic(String).- Parameters:
localUser- the information of the end user, notnulltopicId- the id of the topic to connect to, ornullto not connect the component to any topicpersister- the persister to read/write messages to an external source
-
-
Method Details
-
setTopic
Sets the topic to use with this component. The connection to the previous topic (if any) and existing messages are removed. A connection to the new topic is opened and the list of messages in the new topic are populated to this component.If the topic id is
null, no messages will be displayed.- Parameters:
topicId- the topic id to use, ornullto not use any topic
-
setSubmitter
Sets a submitter to handle the append of messages to the list. It can be used to connect a custom input component as an alternative to the providedCollaborationMessageInput. If set tonullthe existing submitter will be disconnected from the list.- Parameters:
submitter- the submitter, ornullto remove the current submitter
-
setImageProvider
@Deprecated(since="6.5", forRemoval=true) public void setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider) Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.Sets an image provider callback for dynamically loading avatar images for a given user. The image can be loaded on-demand from a database or using any other source of IO streams.If no image callback is defined, then the image URL defined by
UserInfo.getImage()is directly passed to the browser. This means that avatar images need to be available as static files or served dynamically from a custom servlet. This is the default.Usage example:
collaborationMessageList.setImageProvider(userInfo -> { StreamResource streamResource = new StreamResource( "avatar_" + userInfo.getId(), () -> { User userEntity = userRepository .findById(userInfo.getId()); byte[] profilePicture = userEntity.getProfilePicture(); return new ByteArrayInputStream(profilePicture); }); streamResource.setContentType("image/png"); return streamResource; });- Parameters:
imageProvider- the image provider to use, ornullto use image URLs directly from the user info object
-
getImageProvider
@Deprecated(since="6.5", forRemoval=true) public CollaborationAvatarGroup.ImageProvider getImageProvider()Deprecated, for removal: This API element is subject to removal in a future version.UsesetImageHandler(ImageHandler)instead.Gets the currently used image provider callback.- Returns:
- the current image provider callback, or
nullif no callback is set - See Also:
-
setImageHandler
Sets an image handler callback for dynamically loading avatar images for a given user. The image can be loaded on-demand from a database or using any other source of IO streams.If no image handler is defined, then the image URL defined by
UserInfo.getImage()is directly passed to the browser. This means that avatar images need to be available as static files or served dynamically from a custom servlet. This is the default. Usage example:collaborationMessageList.setImageHandler(userInfo -> { DownloadHandler downloadHandler = DownloadHandler .fromInputStream(context -> { User userEntity = userRepository .findById(userInfo.getId()); byte[] profilePicture = userEntity.getProfilePicture(); return new DownloadResponse( new ByteArrayInputStream(profilePicture), "avatar_" + userInfo.getId(), "image/png", -1); }); return downloadHandler; });- Parameters:
imageHandler- the image handler to use, ornullto use image URLs directly from the user info object- Since:
- 6.5
-
getImageHandler
Gets the currently used image handler callback.- Returns:
- the current image handler callback, or
nullif no callback is set - Since:
- 6.5
- See Also:
-
setMessageConfigurator
public void setMessageConfigurator(CollaborationMessageList.MessageConfigurator messageConfigurator) Sets a configurator callback for the messages. It can be used for customizing the properties of theMessageListItemobjects after the component has generated them, before sending them to the user's browser.Usage example:
messageList.setMessageConfigurator((message, user) -> { message.setUserName(user.getName().toUpperCase()); });- Parameters:
messageConfigurator- the configurator to set, ornullto remove the current configurator
-
getMessageConfigurator
Gets the current message configurator, if any.- Returns:
- the current message configurator, or
nullif none has been set - See Also:
-
setMarkdown
public void setMarkdown(boolean markdown) Wrapper method forMessageList.setMarkdown(boolean). 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.
-
isMarkdown
public boolean isMarkdown()Wrapper method forMessageList.isMarkdown(). Returns whether the messages are parsed as markdown.- Returns:
trueif the message text is parsed as Markdown.
-
setAnnounceMessages
public void setAnnounceMessages(boolean announceMessages) Wrapper method forMessageList.setAnnounceMessages(boolean). 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.
-
isAnnounceMessages
public boolean isAnnounceMessages()Wrapper method forMessageList.isAnnounceMessages(). Returns whether new messages are announced to assistive technologies.- Returns:
trueif new messages are announced to assistive technologies.
-
setImageHandler(ImageHandler)instead.