Package io.jmix.aichat.action
Class AiMessageActionPerformedEvent
java.lang.Object
java.util.EventObject
io.jmix.flowui.kit.action.ActionPerformedEvent
io.jmix.aichat.action.AiMessageActionPerformedEvent
- All Implemented Interfaces:
Serializable
Event sent when an
AiMessageAction is performed on a message.
Unlike a plain ActionPerformedEvent, it names the message the action was
invoked on — the whole point of a per-message action — both as the rendered item and
as the domain message that item was rendered from. The triggering component is
the host AiMessageList: the action button itself lives in the client's
shadow DOM and has no server-side counterpart.
Subscribe to it from a view controller by the declared action's id:
@Subscribe("chat.regenerate")
public void onRegenerate(AiMessageActionPerformedEvent event) {
ChatMessage message = event.getMessage(); // the domain message
AiMessageListItem item = event.getItem(); // the rendered item
}
- See Also:
-
Field Summary
FieldsFields inherited from class io.jmix.flowui.kit.action.ActionPerformedEvent
componentFields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionAiMessageActionPerformedEvent(AiMessageAction<?> source, AiMessageList messageList, AiMessageListItem item) -
Method Summary
Modifier and TypeMethodDescriptiongetItem()<M extends AiChatMessage>
@Nullable MGets the domain message the action was invoked on — the message this chat rendered the clicked item from, which is what identifies the persisted row.Methods inherited from class java.util.EventObject
toString
-
Field Details
-
item
-
-
Constructor Details
-
AiMessageActionPerformedEvent
public AiMessageActionPerformedEvent(AiMessageAction<?> source, AiMessageList messageList, AiMessageListItem item) - Parameters:
source- the action that was performedmessageList- the host message listitem- the rendered item the action was invoked on
-
-
Method Details
-
getItem
- Returns:
- the rendered item the action was invoked on (never
null)
-
getMessage
Gets the domain message the action was invoked on — the message this chat rendered the clicked item from, which is what identifies the persisted row. Self-typed, so no cast is needed:ChatMessage message = event.getMessage();- Type Parameters:
M- the application's own message type- Returns:
- the domain message, or
nullwhen the clicked item has none — the transient bubble a stopped or failed generation leaves behind is rendered but never committed, and its action bar is clickable, so a handler that writes to a persisted row must check this
-
getSource
- Overrides:
getSourcein classActionPerformedEvent
-
getComponent
- Overrides:
getComponentin classActionPerformedEvent- Returns:
Componentthat triggered this action.
-