@Parameter

Target: Attribute of a POJO annotated with @ProviderDefinition, @ApplicationDefinition, @ServiceDefinition or @StageDefinition.

Description: Injects a parameter on an entity.

Remarks: The parameter types MUST be objects and NOT primitive types. The allowed objects not a closed set. They can be extended by any developer. See more on this here.

For now DiF supported parameter types are:

  • Long
  • Double
  • String
  • Date
  • Boolean

The DiF's internal parameter manager takes care of the conversion to and from these java types.

JavaDoc: Click here

Attributes:

Name Description Data type Required Default value
id Parameter ID. String No Lower-case version of the parameter name.
constraints The constraints list to apply to the parameter. See the available constraints below. String No None
defaultValue The parameter default value. String No None
linkToForm The name of a form to link to for a parameter validation purposes String No None

Example:

 public class AStage {

    // Declares two mandatory (non-empty) parameters named "username" and "password" on the "login" form

    @Parameter(id = "username", constraints = "required", linkToForm="loginform")
    protected String myUserName;

    @Parameter(id = "password", constraints = "required", linkToForm="loginform")
    protected String myPassword;

    ...
}

Constraints:

  • date: Validates if the input is a valid date. Might be used with regex to define a format for the date. Automatically added for Date typed attributes.
  • alphabetic: Validates the input as an alphabetic value.
  • email: Validates if the input is a valid e-mail.
  • regex: Used to specify an input format. Might be used with any other constraint.
  • maxsize: Sets a maximum size for a string input.
  • minsize: Sets a minimum size for a string input.
  • numeric: Validates the input as a numeric value. Automatically added for Long or Double typed attributes.
  • min: Must be used along with numeric. Sets a floor for an input value.
  • max: Must be used along with numeric. Sets a ceiling for an input value.
  • date: Validates the input as a date value. Automatically added for Date typed attributes.
  • absolutedate: Must be used along with date. Converts 2 digit years to present century dates.
  • relativedate: Must be used along with date. Converts 2 digit years to present year relative dates.
  • pastdate: Must be used along with date. Only allows future dates. Will convert 2 digit years the closest date in the past.
  • futuredate: Must be used along with date. Only allows future dates. Will convert 2 digit years the closest date in the future.
  • readonly: Can be used only on values with default or request value. Makes value changes unavailable.
  • required: Can be used only on values from a submitted form. The parameter is validated by the Dispatcher and any eventual errors are reported and the execution flow is interrupted. The parameter value must not be set to null nor on the request nor on the stage. \
  • Any other custom/third party contributed constraint

See also:

Back to annotation reference