About the Chat category

Chat: ## Note

Vaadin 14.7 has new MessageList component which integrates to Collaboration Engine. See more Message List | Binder and Components | Collaboration Engine | Vaadin Docs

Usage

Create instance of Chat. You can set messages using setMessages(List<Messages>) method.
Messages in list should be sorted from older to newer, as last messages in list will be
shown in bottom of chat and would represent newer messages. Message object contains message text,
sender name, sender avatar(url to avatar image) and indicator whether it’s incoming or outgoing
message(currentUser parameter). Avatar url should not be null but can be empty string. If it’s set to
empty string, image from first letters of first and last names will be create created.
If message have parameter currentUser set to true it means that message is outgoing and
will appear on right sight of chat, else it will be incoming message and appear on left side of chat.

After adding list of messages you, more likely, would like to scroll chat to the bottom,
where newer messages are. You can do that by calling method scrollToBottom().

Chat have text input and Send button. Clicking Send button or clicking Ctrl+Enter will dispatch
vcf-chat-new-message event with users message as parameter.

Use addChatNewMessageListener(ComponentEventListener) to handle event. You can add message to bottom of chat
using method addNewMessage(Message). After message is added you can clear input by calling clearInput
on chat instance.

When user scrolls messages towards top and scrollTop value is smaller then lazyLoadTriggerOffset
parameter of Chat instance, event vcf-chat-trigger-lazy-load will be raised(and will be raising on every
scroll event with debounce time set in debouncePeriod parameter of chat instance).

Use addLazyLoadTriggerEvent(ComponentEventListener) to handle event. You can add older messages
to top of chat using method addMessagesToTop(List<Message>). When vcf-chat-trigger-lazy-load event
is triggered, loading indication is shown in chat and can be disabled by calling setLoading(false) method
on chat instance. Loading also can be enabled manually by calling same method with true value.

Client-side implementation

This is the server-side (Java) API for Vaadin Platform for the vcf-chat component. Looking for the client-side version? It can be found here: vcf-chat - Vaadin Add-on Directory

License & Author

This Add-on is distributed under Apache 2.0

Component Factory Chat is written by Vaadin Ltd.

Sponsored development

Major pieces of development of this add-on has been sponsored by multiple customers of Vaadin. Read more about Expert on Demand at: Support and Pricing