ComponentDialog Class
- java.
lang. Object - com.
microsoft. bot. dialogs. Dialog - com.
microsoft. bot. dialogs. DialogContainer - com.
microsoft. bot. dialogs. ComponentDialog
- com.
- com.
- com.
public class ComponentDialog
extends DialogContainer
A Dialog that is composed of other dialogs. A component dialog has an inner DialogSet and DialogContext ,which provides an inner dialog stack that is hidden from the parent dialog.
Field Summary
| Modifier and Type | Field and Description |
|---|---|
| static final java.lang.String |
PERSISTEDDIALOGSTATE
The id for the persisted dialog state. |
Constructor Summary
| Constructor | Description |
|---|---|
| ComponentDialog(String dialogId) |
Initializes a new instance of the ComponentDialog class. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Component |
addDialog(Dialog dialog)
Adds a new Dialog to the component dialog and returns the updated component. |
|
java.util.concurrent.CompletableFuture<Dialog |
beginDialog(DialogContext outerDc, Object options)
Called when the dialog is started and pushed onto the parent's dialog stack. |
|
java.util.concurrent.CompletableFuture<Dialog |
continueDialog(DialogContext outerDc)
Called when the dialog is _continued_, where it is the active dialog and the user replies with a new activity. |
|
Dialog |
createChildContext(DialogContext dc)
Creates an inner DialogContext . |
|
protected
java.util.concurrent.CompletableFuture<Dialog |
endComponent(DialogContext outerDc, Object result)
Ends the component dialog in its parent's context. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
endDialog(TurnContext turnContext, DialogInstance instance, DialogReason reason)
Called when the dialog is ending. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
ensureInitialized(DialogContext outerDc)
Ensures the dialog is initialized. |
| java.lang.String |
getInitialDialogId()
Gets the id assigned to the initial dialog. |
|
protected
java.util.concurrent.CompletableFuture<Dialog |
onBeginDialog(DialogContext innerDc, Object options)
Called when the dialog is started and pushed onto the parent's dialog stack. |
|
protected
java.util.concurrent.CompletableFuture<Dialog |
onContinueDialog(DialogContext innerDc)
Called when the dialog is _continued_, where it is the active dialog and the user replies with a new activity. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onEndDialog(TurnContext context, DialogInstance instance, DialogReason reason)
Called when the dialog is ending. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onInitialize(DialogContext dc)
Initilizes the dialog. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onRepromptDialog(TurnContext turnContext, DialogInstance instance)
Called when the dialog should re-prompt the user for input. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
repromptDialog(TurnContext turnContext, DialogInstance instance)
Called when the dialog should re-prompt the user for input. |
|
java.util.concurrent.CompletableFuture<Dialog |
resumeDialog(DialogContext outerDc, DialogReason reason, Object result)
Called when a child dialog on the parent's dialog stack completed this turn, returning control to this dialog component. |
| void |
setInitialDialogId(String withInitialDialogId)
Sets the id assigned to the initial dialog. |
Methods inherited from Dialog
Methods inherited from DialogContainer
Methods inherited from java.lang.Object
Field Details
PERSISTEDDIALOGSTATE
public static final String PERSISTEDDIALOGSTATE
The id for the persisted dialog state.
Constructor Details
ComponentDialog
public ComponentDialog(String dialogId)
Initializes a new instance of the ComponentDialog class.
Parameters:
Method Details
addDialog
public ComponentDialog addDialog(Dialog dialog)
Adds a new Dialog to the component dialog and returns the updated component.
Parameters:
Returns:
The added dialog's <xref uid="com.microsoft.bot.dialogs.Dialog.telemetryClient" data-throw-if-not-resolved="false" data-raw-source="Dialog#telemetryClient"></xref> is set to the
<xref uid="com.microsoft.bot.dialogs.DialogContainer.telemetryClient" data-throw-if-not-resolved="false" data-raw-source="DialogContainer#telemetryClient"></xref> of the component dialog.
beginDialog
public CompletableFuture
Called when the dialog is started and pushed onto the parent's dialog stack.
Overrides:
ComponentDialog.beginDialog(DialogContext outerDc, Object options)Parameters:
Returns:
If the task is successful, the result indicates whether the dialog is
still active after the turn has been processed by the dialog.
continueDialog
public CompletableFuture
Called when the dialog is _continued_, where it is the active dialog and the user replies with a new activity.
Overrides:
ComponentDialog.continueDialog(DialogContext outerDc)Parameters:
Returns:
If the task is successful, the result indicates whether the dialog is
still active after the turn has been processed by the dialog. The
result may also contain a return value. If this method is *not*
overridden, the component dialog calls the
<xref uid="com.microsoft.bot.dialogs.DialogContext.continueDialog*" data-throw-if-not-resolved="false" data-raw-source="DialogContext#continueDialog(CancellationToken)"></xref> method on its
inner dialog context. If the inner dialog stack is empty, the
component dialog ends, and if a <xref uid="com.microsoft.bot.dialogs.DialogTurnResult.result" data-throw-if-not-resolved="false" data-raw-source="DialogTurnResult#result"></xref> is
available, the component dialog uses that as its return value.
createChildContext
public DialogContext createChildContext(DialogContext dc)
Creates an inner DialogContext .
Overrides:
ComponentDialog.createChildContext(DialogContext dc)Parameters:
Returns:
endComponent
protected CompletableFuture
Ends the component dialog in its parent's context.
Parameters:
Returns:
If the task is successful, the result indicates that the dialog ended
after the turn was processed by the dialog. In general, the parent
context is the dialog or bot turn handler that started the dialog. If
the parent is a dialog, the stack calls the parent's
<xref uid="com.microsoft.bot.dialogs.Dialog.resumeDialog(com.microsoft.bot.dialogs.DialogContext,com.microsoft.bot.dialogs.DialogReason,java.lang.Object)" data-throw-if-not-resolved="false" data-raw-source="Dialog#resumeDialog(DialogContext, DialogReason, Object)"></xref>
method to return a result to the parent dialog. If the parent dialog
does not implement `ResumeDialog`, then the parent will end, too, and
the result is passed to the next parent context, if one exists. The
returned <xref uid="com.microsoft.bot.dialogs.DialogTurnResult" data-throw-if-not-resolved="false" data-raw-source="DialogTurnResult"></xref> contains the return value in its
<xref uid="com.microsoft.bot.dialogs.DialogTurnResult.result" data-throw-if-not-resolved="false" data-raw-source="DialogTurnResult#result"></xref> property.
endDialog
public CompletableFuture
Called when the dialog is ending.
Overrides:
ComponentDialog.endDialog(TurnContext turnContext, DialogInstance instance, DialogReason reason)Parameters:
Returns:
When this method is called from the parent dialog's context, the
component dialog cancels all of the dialogs on its inner dialog stack
before ending.
ensureInitialized
protected CompletableFuture
Ensures the dialog is initialized.
Parameters:
Returns:
getInitialDialogId
public String getInitialDialogId()
Gets the id assigned to the initial dialog.
Returns:
onBeginDialog
protected CompletableFuture
Called when the dialog is started and pushed onto the parent's dialog stack.
Parameters:
Returns:
If the task is successful, the result indicates whether the dialog is
still active after the turn has been processed by the dialog. By
default, this calls the
<xref uid="com.microsoft.bot.dialogs.Dialog.beginDialog(com.microsoft.bot.dialogs.DialogContext,java.lang.Object)" data-throw-if-not-resolved="false" data-raw-source="Dialog#beginDialog(DialogContext, Object)"></xref> method of the
component dialog's initial dialog, as defined by
InitialDialogId . Override this method in a derived class to
implement interrupt logic.
onContinueDialog
protected CompletableFuture
Called when the dialog is _continued_, where it is the active dialog and the user replies with a new activity.
Parameters:
Returns:
If the task is successful, the result indicates whether the dialog is
still active after the turn has been processed by the dialog. The
result may also contain a return value. By default, this calls the
currently active inner dialog's
<xref uid="com.microsoft.bot.dialogs.Dialog.continueDialog(com.microsoft.bot.dialogs.DialogContext)" data-throw-if-not-resolved="false" data-raw-source="Dialog#continueDialog(DialogContext)"></xref> method. Override this
method in a derived class to implement interrupt logic.
onEndDialog
protected CompletableFuture
Called when the dialog is ending.
Parameters:
Returns:
Override this method in a derived class to implement any additional
logic that should happen at the component level, after all inner
dialogs have been canceled.
onInitialize
protected CompletableFuture
Initilizes the dialog.
Parameters:
Returns:
onRepromptDialog
protected CompletableFuture
Called when the dialog should re-prompt the user for input.
Parameters:
Returns:
Override this method in a derived class to implement any additional
logic that should happen at the component level, after the re-prompt
operation completes for the inner dialog.
repromptDialog
public CompletableFuture
Called when the dialog should re-prompt the user for input.
Overrides:
ComponentDialog.repromptDialog(TurnContext turnContext, DialogInstance instance)Parameters:
Returns:
resumeDialog
public CompletableFuture
Called when a child dialog on the parent's dialog stack completed this turn, returning control to this dialog component.
Overrides:
ComponentDialog.resumeDialog(DialogContext outerDc, DialogReason reason, Object result)Parameters:
Returns:
If the task is successful, the result indicates whether this dialog
is still active after this dialog turn has been processed. Generally,
the child dialog was started with a call to
BeginDialog(DialogContext, Object) in the parent's context.
However, if the <xref uid="com.microsoft.bot.dialogs.DialogContext.replaceDialog(java.lang.String,java.lang.Object)" data-throw-if-not-resolved="false" data-raw-source="DialogContext#replaceDialog(String, Object)"></xref>
method is called, the logical child dialog may be different than the
original. If this method is *not* overridden, the dialog
automatically calls its RepromptDialog(TurnContext,
DialogInstance) when the user replies.
setInitialDialogId
public void setInitialDialogId(String withInitialDialogId)
Sets the id assigned to the initial dialog.
Parameters: