Announcement Announcement Module
No announcement yet.
Problems with float fields (customEditor and valitation) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with float fields (customEditor and valitation)


    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

    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, 11:13 AM.

  • #2
    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
      I was doing stupid mistake, thanks for your help katentim