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:
  • Field Details

    • ROUTE_PARAM_ID

      public static final String ROUTE_PARAM_ID
      See Also:
    • conversationService

      @Autowired protected AiConversationService conversationService
    • urlParamSerializer

      @Autowired protected UrlParamSerializer urlParamSerializer
    • routeSupport

      @Autowired protected RouteSupport routeSupport
    • viewNavigators

      @Autowired protected ViewNavigators viewNavigators
    • dialogs

      @Autowired protected Dialogs dialogs
    • messageBundle

      @ViewComponent protected MessageBundle messageBundle
    • chatFragment

      @ViewComponent protected AiChatFragment chatFragment
    • notFoundLayout

      @ViewComponent protected com.vaadin.flow.component.orderedlayout.VerticalLayout notFoundLayout
    • emptyLayout

      @ViewComponent protected com.vaadin.flow.component.orderedlayout.VerticalLayout emptyLayout
    • conversation

      protected @Nullable AiConversation 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:
      beforeEnter in interface com.vaadin.flow.router.internal.BeforeEnterHandler
      Overrides:
      beforeEnter in class View<ViewLayout>
    • onReady

      @Subscribe public void onReady(View.ReadyEvent event)
    • setConversation

      public void setConversation(@Nullable AiConversation conversation)
      Binds a conversation to the hosted fragment programmatically. If the view is already shown the conversation is applied immediately, otherwise it is applied on ReadyEvent. 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, or null to show the empty state
    • sendInitialPrompt

      public void sendInitialPrompt(@Nullable String prompt)
      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; a null or blank value is ignored
    • loadConversationFromRouteParameters

      protected void loadConversationFromRouteParameters(com.vaadin.flow.router.BeforeEnterEvent event)
    • onBeforeClose

      @Subscribe public void onBeforeClose(View.BeforeCloseEvent event)
    • showLeaveWhileRespondingDialog

      protected void showLeaveWhileRespondingDialog(Runnable onLeave, Runnable onStay)
    • proceedWithNavigation

      protected OperationResult proceedWithNavigation(com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction navigationAction)
    • 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()
    • syncUrl

      protected void syncUrl()