Class MessageListUser
java.lang.Object
com.vaadin.flow.component.messages.MessageListUser
- All Implemented Interfaces:
Serializable
A user of a
MessageList, rendered as an avatar with a name in the
typing indicator of the list.
Use a separate instance for each message list. An avatar image that is set
with setImageHandler(DownloadHandler) is served as a resource of the
message list that the user was added to last.
- Since:
- 25.3
- Author:
- Vaadin Ltd.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty user.MessageListUser(String name) Creates a user with the given name.MessageListUser(String name, String imageUrl) Creates a user with the given name and image URL. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClassNames(String... classNames) Adds one or more class names to the avatar of this user.Gets the abbreviation of the user.Gets the class names set on the avatar of this user.Gets the color index of the user.getImage()Gets the URL of the avatar image.Gets the download handler that serves the avatar image.getName()Gets the name of the user.voidremoveClassNames(String... classNames) Removes one or more class names from the avatar of this user.voidsetAbbreviation(String abbreviation) Sets the abbreviation of the user.voidsetColorIndex(Integer colorIndex) Sets the color index of the user.voidSets the URL of the avatar image.voidsetImageHandler(DownloadHandler downloadHandler) Sets a download handler that serves the avatar image.voidSets the name of the user.
-
Constructor Details
-
MessageListUser
public MessageListUser()Creates an empty user. Use the setter methods to configure what is displayed in the avatar. -
MessageListUser
Creates a user with the given name.- Parameters:
name- the name of the user- See Also:
-
MessageListUser
Creates a user with the given name and image URL.- Parameters:
name- the name of the userimageUrl- the URL of the avatar image- See Also:
-
-
Method Details
-
getName
Gets the name of the user.- Returns:
- the name of the user, or
nullif no name has been set
-
setName
Sets the name of the user. The name is displayed next to the avatar, and identifies the user within the message list.- Parameters:
name- the name of the user, ornullto remove the name
-
getAbbreviation
Gets the abbreviation of the user.- Returns:
- the abbreviation, or
nullif no abbreviation has been set
-
setAbbreviation
Sets the abbreviation of the user. The abbreviation is displayed in the avatar when no image has been set. By default, the abbreviation is deduced from the name.- Parameters:
abbreviation- the abbreviation, ornullto remove the abbreviation
-
getImage
Gets the URL of the avatar image.When the image is set with
setImageHandler(DownloadHandler), this returns the URL that the handler is served from, ornullwhile the user does not belong to an attached message list.- Returns:
- the image URL, or
nullif no image has been set
-
setImage
Sets the URL of the avatar image. The image is displayed in the avatar even when a name or an abbreviation has been set.This removes an image set with
setImageHandler(DownloadHandler).- Parameters:
imageUrl- the image URL, ornullto remove the image
-
getImageHandler
Gets the download handler that serves the avatar image.- Returns:
- the download handler, or
nullif the image has not been set withsetImageHandler(DownloadHandler)
-
setImageHandler
Sets a download handler that serves the avatar image. The handler is registered as a resource of the message list that the user belongs to, and is unregistered when the user is removed from the list or the list is detached.The
Content-Dispositionheader is set toinlinefor the handlers created by the factory methods inDownloadHandler, as well as for otherAbstractDownloadHandlerimplementations.This removes an image URL set with
setImage(String).- Parameters:
downloadHandler- the download handler, ornullto remove the image
-
getColorIndex
Gets the color index of the user.- Returns:
- the color index, or
nullif no color index has been set
-
setColorIndex
Sets the color index of the user. Color index N applies the CSS variable--vaadin-user-color-Nto the border of the avatar.- Parameters:
colorIndex- the color index, ornullto remove the color index
-
addClassNames
Adds one or more class names to the avatar of this user.- Parameters:
classNames- the class names to add
-
removeClassNames
Removes one or more class names from the avatar of this user.- Parameters:
classNames- the class names to remove
-
getClassName
Gets the class names set on the avatar of this user.- Returns:
- a space-delimited list of class names, or
nullif no class names have been set
-