You can define input and output variables for custom states. Variables are used as both metadata in the state editor, and as runtime objects for storing session variables.
// Define input variable private static final TextBoxAttribute inPostCode = new TextBoxAttribute("POSTCODE", "Zip or Postal Code", false); // Define output variable private static final OutputAttribute outWeather = new OutputAttribute("WEATHER", "Your Weather Synopsis"); private static Attribute[] stateAttr; static { stateAttr = new Attribute[] {inPostCode, outWeather}; } @Override protected Attribute[] getStateAttributes() { return stateAttr.clone(); }
getStateAttributes is an abstract helper method that the SmappStatePlugin class implements. It aggregates both input and output variables. The base class derives the required getInputAttributes and getOutputAttributes methods from getStateAttributes, based on the attribute-type class. The state editor uses the attribute array that the getStateAttributes method returns to render input and output variables. The saveOutputAttributes method saves output attributes from the attribute array.
All variables (input and output) have input controls that appear on the state editor. The public String getText() method returns the text from input controls.