1 Reply Latest reply: Sep 19, 2012 3:00 AM by Kayaman RSS

    javax validation

    csckid
      I have integrated javax validation with my swing app.
      class Department{
              private String name;
             @NotNull
              private String code;
            @Size(min=8)
           public String getName(){..}
      ...
      }
      
      TextField Name;
      TextField code;
      On textfield focus change I want to validate department pojo. If Name field size is below 8 I want to focus the Name textfield.
      Set<ConstraintViolation<Department>> violations = validator.validate(department);
      Using this code I could get all the errors found.
      Question) I don't know how to write the code which will tell me Name field entry is wrong. I want to get the textfield name so that I could focus that textfield
      Question) Do we use javax validation for this purpose, or do we use to check if entire pojo is correct before submitting.