Confirmation

The confirmation component asks a user for a simple confirmation. It is essentially a yes-or-no question.spring-doc.cn

@ShellComponent
public class ComponentCommands extends AbstractShellComponent {

	@ShellMethod(key = "component confirmation", value = "Confirmation input", group = "Components")
	public String confirmationInput(boolean no) {
		ConfirmationInput component = new ConfirmationInput(getTerminal(), "Enter value", !no);
		component.setResourceLoader(getResourceLoader());
		component.setTemplateExecutor(getTemplateExecutor());
		ConfirmationInputContext context = component.run(ConfirmationInputContext.empty());
		return "Got value " + context.getResultValue();
	}
}

The following screencast shows the typical output from a confirmation component:spring-doc.cn

The context object is ConfirmationInputContext. The following table describes its context variables:spring-doc.cn

Table 1. ConfirmationInputContext Template Variables
Key Description

defaultValuespring-doc.cn

The default value — either true or false.spring-doc.cn

modelspring-doc.cn

The parent context variables (see TextComponentContext Template Variables).spring-doc.cn