Annotation Type Required


@Retention(CLASS) @Target(FIELD) public @interface Required

Marks a @Bind field whose component must hold a non-empty value. The binder generated by the Codename One Maven plugin installs a com.codename1.ui.validation.LengthConstraint(1) on the matching component and wires it into the Validator returned by Binding#getValidator().

@Bindable
public class SignupModel {
    @Bind(name="userField") @Required
    private String user;
}

Stack with other validation annotations -- the constraints are combined (AND) via Validator.addConstraint(Component, Constraint...). The first failing constraint's message is shown.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Override the default error message ("A value is required").
  • Element Details

    • message

      String message
      Override the default error message ("A value is required").
      Default:
      ""