public class CollaborationMessageList extends Composite<MessageList> implements HasSize, HasStyle
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.Modifier and Type | Class and Description |
---|---|
static interface |
CollaborationMessageList.MessageConfigurator
Configurator callback for messages in a
CollaborationMessageList . |
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. |
Modifier and Type | Method and Description |
---|---|
CollaborationAvatarGroup.ImageProvider |
getImageProvider()
Gets the currently used image provider callback.
|
CollaborationMessageList.MessageConfigurator |
getMessageConfigurator()
Gets the current message configurator, if any.
|
void |
setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
Sets an image provider callback for dynamically loading avatar images for
a given user.
|
void |
setMessageConfigurator(CollaborationMessageList.MessageConfigurator messageConfigurator)
Sets a configurator callback for the messages.
|
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.
|
getChildren, getContent, getElement, initContent
addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
getElement
addAttachListener
addDetachListener
public CollaborationMessageList(UserInfo localUser, String topicId)
It renders messages received by a CollaborationMessageInput
or a
custom submitter component connected to this list via
setSubmitter(CollaborationMessageSubmitter)
If a null
topic id is provided, the component won't display any
messages, until connecting to a non-null topic with
setTopic(String)
.
localUser
- the information of the end user, not null
topicId
- the id of the topic to connect to, or null
to not
connect the component to any topicpublic CollaborationMessageList(UserInfo localUser, String topicId, CollaborationMessagePersister persister)
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 via
setSubmitter(CollaborationMessageSubmitter)
If a null
topic id is provided, the component won't display any
messages, until connecting to a non-null topic with
setTopic(String)
.
localUser
- the information of the end user, not null
topicId
- the id of the topic to connect to, or null
to not
connect the component to any topicpersister
- the persister to read/write messages to an external sourcepublic void setTopic(String topicId)
If the topic id is null
, no messages will be displayed.
topicId
- the topic id to use, or null
to not use any topicpublic void setSubmitter(CollaborationMessageSubmitter submitter)
CollaborationMessageInput
. If set to null
the
existing submitter will be disconnected from the list.submitter
- the submitter, or null
to remove the current submitterpublic void setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
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; });
imageProvider
- the image provider to use, or null
to use image
URLs directly from the user info objectpublic CollaborationAvatarGroup.ImageProvider getImageProvider()
null
if no
callback is set#setImageProvider(ImageProvider)
public void setMessageConfigurator(CollaborationMessageList.MessageConfigurator messageConfigurator)
MessageListItem
objects 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()); });
messageConfigurator
- the configurator to set, or null
to remove the current
configuratorpublic CollaborationMessageList.MessageConfigurator getMessageConfigurator()
null
if none has
been setsetMessageConfigurator(MessageConfigurator)
Copyright © 2022. All rights reserved.