Results 1 to 3 of 3

Thread: Problems with float fields (customEditor and valitation)

  1. #1
    Join Date
    Jan 2006
    Location
    Spain
    Posts
    44

    Default Problems with float fields (customEditor and valitation)

    Hi!

    I have one form with two fields. The first field is "ID" and the user has to put an Integer. The second field is "Prize" and the user has to put a float number.

    In my validation class I have the following code:

    ValidationUtils.rejectIfEmpty(errors,"ID","fieldNu ll","*");
    ValidationUtils.rejectIfEmpty(errors,"Prize","fiel dNull","*");
    My init binder

    super.initBinder(request,binder);
    NumberFormat nf = NumberFormat.getNumberInstance();
    binder.registerCustomEditor(Float.class,"Prize", new CustomNumberEditor(Float.class,nf,true));
    NumberFormat nf2 = NumberFormat.getIntegerInstance();
    binder.registerCustomEditor(Integer.class,"ID", new CustomNumberEditor(Integer.class,nf2,true));
    When an user press the button of the form and the fields are empty the form shows:

    ID -> *
    Prize -> Failed to convert propertu value of type lang... bla bla bla

    Someone knows the reason? I want to get "*" in a Prize field too.
    Last edited by olope; May 23rd, 2006 at 11:13 AM.

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    The second field is "Prize" and the user has to put a float number
    Is that float the primitive or Float the class? If you're using a primitive, you'll get this error as you can't have a primitive set to null.

  3. #3
    Join Date
    Jan 2006
    Location
    Spain
    Posts
    44

    Default

    I was doing stupid mistake, thanks for your help katentim

Posting Permissions

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