Class ChatAssistant

All Implemented Interfaces:
AttachNotifier, ClickNotifier<Div>, DetachNotifier, HasComponents, HasElement, HasEnabled, HasOrderedComponents, HasSize, HasStyle, HasText, Serializable

@NpmPackage(value="wc-chatbot", version="0.2.0") @JsModule("wc-chatbot/dist/wc-chatbot.js") @CssImport("./styles/chat-assistant-styles.css") @Tag("chat-bot") public class ChatAssistant extends Div
Component that allows to create a floating chat button that will open a chat window that can be used to provide a chat assistant feature.
Author:
mmlopez
See Also:
  • Constructor Details

    • ChatAssistant

      public ChatAssistant()
      Default constructor. Creates a ChatAssistant with no messages.
    • ChatAssistant

      public ChatAssistant(boolean markdownEnabled)
      Creates a ChatAssistant with no messages.
      Parameters:
      markdownEnabled - flag to enable or disable markdown support
    • ChatAssistant

      public ChatAssistant(List<Message> messages, boolean markdownEnabled)
      Creates a ChatAssistant with the given list of messages.
      Parameters:
      messages - the list of messages
      markdownEnabled - flag to enable or disable markdown support
  • Method Details

    • setDataProvider

      public void setDataProvider(DataProvider<Message,?> dataProvider)
      Sets the data provider of the internal VirtualList.
      Parameters:
      dataProvider - the data provider to be used
    • setWhoIsTyping

      public void setWhoIsTyping(String whoIsTyping)
      Uses the provided string as the text shown over the message input to indicate that someone is typing.
      Parameters:
      whoIsTyping - string to be shown as an indication of someone typing
    • getWhoIsTyping

      public String getWhoIsTyping()
      Returns the current text shown over the message input to indicate that someone is typing.
      Returns:
      the current text or null if not configured
    • clearWhoIsTyping

      public void clearWhoIsTyping()
      Clears the text shown over the message input to indicate that someone is typing.
    • setSubmitListener

      public Registration setSubmitListener(ComponentEventListener<MessageInput.SubmitEvent> listener)
      Sets the SubmitListener that will be notified when the user submits a message on the underlying messageInput.
      Parameters:
      listener - the listener that will be notified when the SubmitEvent is fired
      Returns:
      registration for removal of the listener
    • onAttach

      protected void onAttach(AttachEvent attachEvent)
      Overrides:
      onAttach in class Component
    • sendMessage

      public void sendMessage(Message message)
      Sends a message programmatically to the component. Should not be used when a custom DataProvider is used. Instead just refresh the custom DataProvider.
      Parameters:
      message - the message to be sent programmatically
    • updateMessage

      public void updateMessage(Message message)
      Updates a previously entered message.
      Parameters:
      message - the message to be updated
    • setMinimized

      public void setMinimized(boolean minimized)
      Shows or hides chat window.
      Parameters:
      minimized - true for hiding the chat window and false for displaying it
    • isMinimized

      public boolean isMinimized()
      Returns the visibility of the chat window.
      Returns:
      true if the chat window is minimized false otherwise
    • setHeaderComponent

      public void setHeaderComponent(Component component)
      Allows changing the header of the chat window.
      Parameters:
      component - to be used as a replacement for the header
    • getHeaderComponent

      public Component getHeaderComponent()
      Returns the current component configured as the header of the chat window.
      Returns:
      component used as the header of the chat window
    • setFooterComponent

      public void setFooterComponent(Component component)
      Allows changing the footer of the chat window.
      Parameters:
      component - to be used as a replacement for the footer, it cannot be null
    • getFooterComponent

      public Component getFooterComponent()
      Returns the current component configured as the footer of the chat window.
      Returns:
      component used as the footer of the chat window
    • scrollToIndex

      public void scrollToIndex(int position)
      Scrolls to the given position. Scrolls so that the element is shown at the start of the visible area whenever possible.

      If the index parameter exceeds current item set size the grid will scroll to the end.

      Parameters:
      position - zero based index of the item to scroll to in the current view.
    • scrollToStart

      public void scrollToStart()
      Scrolls to the first element.
    • scrollToEnd

      public void scrollToEnd()
      Scrolls to the last element of the list.