You can access input variables that are in a custom state using either the
getInputValue method or the
getInputValueWithWarning method.
The signatures of the methods you can call to access input variables
are:
public InputValue getInputValue()
throws DBException;
public InputValue getInputValueWithWarning()
throws DBException, RequiredParameterMissingException;
To retrieve optional input variables, call
getInputValue. A null value
is returned if either an input variable is not provided, or if the session variable that
the input variable is assigned to does not exist.
InputValue iv = optionalVar.getInputValue();
if (iv != null) {
retrieve the value
}
To retrieve mandatory input variables, call
getInputValueWithWarning.
The exception
RequiredParameterMissingException is raised if either
an input variable is not provided, or if the session variable that the input variable is
assigned to does not exist. You can retrieve all mandatory input variables in the same
try/catch block.
try {
Long id = mandatoryIdVar.getInputValueWithWarning().getLong();
Integer count = mandatoryCountVar.getInputValueWithWarning().getInt();
}
catch (RequiredParameterMissingException rex) {
log.error(rex.getMessage());
return continueFail();
}
Note: The
RequiredParameterMissingException::getMessage
method indicates the mandatory variable that is missing.
Both methods that access input variables return the
InputValue class.
InputValue methods return values that you enter in the state
editor when you configure an input attribute; return values can be either constants or
session-variable names:
- InputValue.getString();
- InputValue.getString(int size);
- InputValue.getLong();
- InputValue.getInt();
- InputValue.getBoolean();
- InputValue.getDouble();
- InputValue.getMsisdn();