|
This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Shell 3.4.1! |
Number Input
The number input component asks a user for simple number input. It can be configured to use any implementation of Number.class. The following listing shows an example:
NumberInput component = new NumberInput(getTerminal(), "Enter value", 99.9, Double.class);
ResourceLoader resourceLoader = null; // getResourceLoader();
TemplateExecutor templateExecutor = null; // getTemplateExecutor();
component.setResourceLoader(resourceLoader);
component.setTemplateExecutor(templateExecutor);
NumberInputContext context = component.run(NumberInputContext.empty());
return "Got value " + context.getResultValue();
The following image shows typical output from a number input component:
The context object is NumberInputContext. The following table lists its context variables:
| Key | Description |
|---|---|
|
The default value, if set. Otherwise, null. |
|
The default number class to use, if set. Otherwise, Integer.class. |
|
|
|
The parent context variables (see TextComponentContext Template Variables). |