Package io.jmix.aitoolsflowui.view.input
Class AiChatInputFragment
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.orderedlayout.VerticalLayout>
io.jmix.flowui.fragment.Fragment<com.vaadin.flow.component.orderedlayout.VerticalLayout>
io.jmix.aitoolsflowui.view.input.AiChatInputFragment
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,FacetOwner,FragmentOwner,Serializable
public class AiChatInputFragment
extends Fragment<com.vaadin.flow.component.orderedlayout.VerticalLayout>
Reusable chat input ("composer"). Replaces the stock Vaadin
MessageInput with a
JmixTextArea + send JmixButton, so it can be embedded both in
the timeline (AiChatFragment) and on the chat hub screen.
Submit gesture. Enter submits; Shift+Enter inserts a newline. The
server-side submit fires only for a bare Enter (DOM keydown filter) and the
newline insertion is suppressed client-side via preventDefault.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.flowui.fragment.Fragment
Fragment.ReadyEvent -
Field Summary
FieldsFields inherited from class io.jmix.flowui.fragment.Fragment
fragmentActions, fragmentData, fragmentFacets, parentController, uiComponents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the input text.voidfocus()Moves keyboard focus to the input.getValue()Returns the current input text.booleanReturns whether the input is enabled.protected voidonReady(Fragment.ReadyEvent event) voidsetInputEnabled(boolean enabled) Enables/disables the input and the send button together.voidsetPlaceholder(@Nullable String placeholder) Sets the placeholder text of the input.voidsetSubmitHandler(@Nullable Consumer<String> submitHandler) Sets the handler invoked with the trimmed, non-blank message text when the user submits.protected voidsubmit()Methods inherited from class io.jmix.flowui.fragment.Fragment
addReadyListener, findInnerComponent, getFragmentActions, getFragmentData, getFragmentFacets, getInnerComponent, getParentController, initContent, onAttach, onDetach, setFragmentActions, setFragmentData, setFragmentFacets, setParentController, setUiComponentsMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface io.jmix.flowui.facet.FacetOwner
getIdMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
messageField
-
sendButton
-
submitHandler
-
-
Constructor Details
-
AiChatInputFragment
public AiChatInputFragment()
-
-
Method Details
-
setSubmitHandler
Sets the handler invoked with the trimmed, non-blank message text when the user submits. Passingnullrestores a no-op handler.- Parameters:
submitHandler- handler invoked with the submitted text, ornullfor a no-op
-
setPlaceholder
Sets the placeholder text of the input.- Parameters:
placeholder- placeholder text, ornullfor none
-
setInputEnabled
public void setInputEnabled(boolean enabled) Enables/disables the input and the send button together.- Parameters:
enabled-trueto enable the input and the send button
-
isInputEnabled
public boolean isInputEnabled()Returns whether the input is enabled.- Returns:
trueif the input is enabled
-
focus
public void focus()Moves keyboard focus to the input. No-op if the input is disabled. -
clear
public void clear()Clears the input text. -
getValue
Returns the current input text.- Returns:
- current text (empty string if nothing was entered)
-
onReady
-
submit
protected void submit()
-