com.vaadin.collaborationengine.
Class CollaborationMessageList
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.Composite<MessageList>
-
- com.vaadin.collaborationengine.CollaborationMessageList
-
All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasElement, HasSize, HasStyle, Serializable
public class CollaborationMessageList extends Composite<MessageList> implements HasSize, HasStyle
Extension of the
MessageList
component which integrates with theCollaborationEngine
. 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 theCollaborationMessageInput
component for submitting messages.Author:
Vaadin Ltd
See Also:
-
-
Constructor Summary
Constructors Constructor and Description CollaborationMessageList(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 of
CollaborationMessage
items from/to an external source (e.g.
-
Method Summary
All Methods Modifier and Type Method and Description CollaborationAvatarGroup.ImageProvider
getImageProvider()
Gets the currently used image provider callback.
void
setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
Sets an image provider callback for dynamically loading avatar images for a given user.
void
setSubmitter(CollaborationMessageSubmitter submitter)
Sets a submitter to handle the append of messages to the list.
void
setTopic(String topicId)
Sets the topic to use with this component.
-
Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContent
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
-
-
-
Constructor Detail
-
CollaborationMessageList
public CollaborationMessageList(UserInfo localUser, String topicId)
Creates a new collaboration message list component with the provided topic id.
It renders messages received by a
CollaborationMessageInput
or a custom submitter component connected to this list viasetSubmitter(CollaborationMessageSubmitter)
If a
null
topic 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, notnull
topicId
- the id of the topic to connect to, ornull
to 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 of
CollaborationMessage
items from/to an external source (e.g. a database).It renders messages received by a
CollaborationMessageInput
or a custom submitter component connected to this list viasetSubmitter(CollaborationMessageSubmitter)
If a
null
topic 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, notnull
topicId
- the id of the topic to connect to, ornull
to not connect the component to any topicpersister
- the persister to read/write messages to an external source
-
-
Method Detail
-
setTopic
public void setTopic(String topicId)
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, ornull
to not use any topic
-
setSubmitter
public void setSubmitter(CollaborationMessageSubmitter submitter)
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 provided
CollaborationMessageInput
. If set tonull
the existing submitter will be disconnected from the list.Parameters:
submitter
- the submitter, ornull
to remove the current submitter
-
setImageProvider
public void setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
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, ornull
to use image URLs directly from the user info object
-
getImageProvider
public CollaborationAvatarGroup.ImageProvider getImageProvider()
Gets the currently used image provider callback.
Returns:
the current image provider callback, or
null
if no callback is setSee Also:
#setImageProvider(ImageProvider)
-
-