Package io.jmix.aitoolsflowui.view.chat
Class AiChatView
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<ViewLayout>
io.jmix.flowui.view.View<ViewLayout>
io.jmix.flowui.view.StandardView
io.jmix.aitoolsflowui.view.chat.AiChatView
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,com.vaadin.flow.router.AfterNavigationObserver,com.vaadin.flow.router.BeforeEnterObserver,com.vaadin.flow.router.BeforeLeaveObserver,com.vaadin.flow.router.HasDynamicTitle,com.vaadin.flow.router.internal.AfterNavigationHandler,com.vaadin.flow.router.internal.BeforeEnterHandler,com.vaadin.flow.router.internal.BeforeLeaveHandler,FacetOwner,FragmentOwner,Serializable
@Route(value="aitls/chat/:id?",
layout=DefaultMainViewParent.class)
@ViewController(id="aitls_AiChatView")
@ViewDescriptor("ai-chat-view.xml")
public class AiChatView
extends StandardView
Standalone host view around
AiChatFragment.
Opens either by URL — the :id route segment is the id of an
AiConversation that gets loaded and bound to the fragment — or
programmatically via setConversation(AiConversation) (used by
DialogWindows and after-navigation handlers).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.flowui.view.View
View.AfterCloseEvent, View.BeforeCloseEvent, View.BeforeShowEvent, View.InitEvent, View.PostReadyEvent, View.QueryParametersChangeEvent, View.ReadyEvent, View.RestoreComponentsStateEvent -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AiChatFragmentprotected booleanprotected @Nullable AiConversationprotected booleanprotected AiConversationServiceprotected Dialogsprotected com.vaadin.flow.component.orderedlayout.VerticalLayoutprotected booleanprotected booleanprotected MessageBundleprotected com.vaadin.flow.component.orderedlayout.VerticalLayoutstatic final Stringprotected RouteSupportprotected UrlParamSerializerprotected ViewNavigators -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidapplyPageTitle(@Nullable String title) Makes the conversation title the title of this view, so that the browser page title and, in Tabbed Mode, the tab title identify the conversation.voidbeforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) protected voidloadConversationFromRouteParameters(com.vaadin.flow.router.BeforeEnterEvent event) protected voidvoidvoidonInit(View.InitEvent event) voidonNewChatBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) voidonNotFoundNewChatBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) voidonReady(View.ReadyEvent event) protected @Nullable UUIDparseConversationId(String rawId) protected OperationResultproceedWithNavigation(com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction navigationAction) protected voidprocessBeforeEnterInternal(com.vaadin.flow.router.BeforeEnterEvent event) CAUTION: for internal use only.voidsendInitialPrompt(@Nullable String prompt) Sends an initial user prompt into the bound conversation, used by the chat hub's navigation handler.voidsetConversation(@Nullable AiConversation conversation) Binds a conversation to the hosted fragment programmatically.protected voidshowLeaveWhileRespondingDialog(Runnable onLeave, Runnable onStay) protected voidsyncUrl()Methods inherited from class io.jmix.flowui.view.View
addAfterCloseListener, addApplicationListeners, addBeforeCloseListener, addBeforeShowListener, addInitListener, addQueryParametersChangeListener, addReadyListener, addRestoreComponentsStateEventListener, afterNavigation, beforeLeave, close, close, closeWithDefaultAction, configureDialogWindowFooter, configureDialogWindowHeader, getApplicationContext, getEventBus, getId, getPageTitle, getReturnParameters, getViewActions, getViewAttributes, getViewData, getViewFacets, getViewSupport, isPreventBrowserTabClosing, onAttach, onAttachInternal, onDetach, onDetachInternal, removeApplicationListeners, removeViewAttributes, setAfterNavigationHandler, setApplicationContext, setId, setPageTitle, setPreventBrowserTabClosing, setViewActions, setViewData, setViewFacets, unregisterBackNavigationMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setTestId, setVisible, whenAttachedMethods 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 com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
ROUTE_PARAM_ID
- See Also:
-
conversationService
-
urlParamSerializer
-
routeSupport
-
dialogs
-
messageBundle
-
chatFragment
-
notFoundLayout
-
emptyLayout
-
conversation
-
conversationNotFound
protected boolean conversationNotFound -
contentInitialized
protected boolean contentInitialized -
initialPromptSent
protected boolean initialPromptSent -
leaveConfirmed
protected boolean leaveConfirmed
-
-
Constructor Details
-
AiChatView
public AiChatView()
-
-
Method Details
-
beforeEnter
public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) - Specified by:
beforeEnterin interfacecom.vaadin.flow.router.internal.BeforeEnterHandler- Overrides:
beforeEnterin classView<ViewLayout>
-
processBeforeEnterInternal
protected void processBeforeEnterInternal(com.vaadin.flow.router.BeforeEnterEvent event) Description copied from class:ViewCAUTION: for internal use only.- Overrides:
processBeforeEnterInternalin classView<ViewLayout>- Parameters:
event- before navigation event with event details
-
onInit
-
onReady
-
setConversation
Binds a conversation to the hosted fragment programmatically. If the view is already shown the conversation is applied immediately, otherwise it is applied onReadyEvent. Clears any previous "not found" state and keeps the browser URL in sync (unless the view is opened in a dialog).- Parameters:
conversation- conversation to bind, ornullto show the empty state
-
sendInitialPrompt
Sends an initial user prompt into the bound conversation, used by the chat hub's navigation handler. Idempotent: runs at most once per view instance, so a re-fired navigation handler cannot double-submit. No-op when no conversation is bound (e.g. the id did not resolve).- Parameters:
prompt- initial prompt text; anullor blank value is ignored
-
loadConversationFromRouteParameters
protected void loadConversationFromRouteParameters(com.vaadin.flow.router.BeforeEnterEvent event) -
onBeforeClose
-
showLeaveWhileRespondingDialog
-
onNewChatBtnClick
@Subscribe(id="newChatBtn", subject="clickListener") public void onNewChatBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) -
onNotFoundNewChatBtnClick
@Subscribe(id="notFoundNewChatBtn", subject="clickListener") public void onNotFoundNewChatBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) -
applyConversation
protected void applyConversation() -
applyPageTitle
Makes the conversation title the title of this view, so that the browser page title and, in Tabbed Mode, the tab title identify the conversation. A blank title falls back to the static view title.- Parameters:
title- conversation title, ornullto fall back to the static view title
-
syncUrl
protected void syncUrl() -
parseConversationId
-