Results 1 to 7 of 7

Thread: Suppress Date Error (Annotation)

  1. #1
    Join Date
    Mar 2008
    Posts
    5

    Default Suppress Date Error (Annotation)

    Hi,

    i use the initBinder to check a date.
    i also use a @NotNull annotation for this date.

    The problem is that i get 2 errors when i have a wrong date.
    1. Init Binder Error
    2. Date is NotNull

    Is there a possibility to suppress the annotation error, when the initbinder throws an error ?

  2. #2
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    What error does the initBinder throw?

  3. #3
    Join Date
    Mar 2008
    Posts
    5

    Default

    typeMismatch.java.util.Date

  4. #4
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    I think it's typeMismatch.fieldName

  5. #5
    Join Date
    Mar 2008
    Posts
    5

    Default

    I define a initBinder like that:

    SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.GERMAN);
    df.setLenient(false);
    CustomDateEditor editor = new CustomDateEditor(df, true, ZEHN);
    binder.registerCustomEditor(Date.class, editor);

    --> When the User enter a wrong date like : 32534
    i get :

    typeMismatch.java.util.Date exception
    AND
    I get my notnull exception
    @NotNull(message = "blabla")
    private Date datefield;

  6. #6
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    If you have a error resource bundle configured just put a new entry in it with the key typeMismatch.fieldName. Whenever there is an exception while parsing the data, the error will show up instead of an exception.

  7. #7
    Join Date
    Mar 2008
    Posts
    5

    Default

    this is clear. The Problem that i want to suppress the @NotNull Annotation when i have a typeMismatch.fieldName exception.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •