Announcement Announcement Module
No announcement yet.
Null values into CustomNumberEditor for BigDecimal.class Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Null values into CustomNumberEditor for BigDecimal.class

    I may be having a duh! moment here, but I'm confused by the behaviour of the CustomNumberEditor when handling a BigDecimal conversion.

    I'm registering the CNE under a AbstractWizardFormController.initBinder operation using the following code:

    NumberFormat managerIdFormat = NumberFormat.getInstance();
    binder.registerCustomEditor(BigDecimal.class, "managerId", new, CustomNumberEditor(BigDecimal.class, managerIdFormat, true));
    I'm expecting the 3rd constructor arg into CustomNumberEditor (i.e. true) to make it tolerant of null values coming in from the form. However, I'm still getting a typeMismatch String->BigDecimal that does complain about a null value.

    I've tried tests on CNE in a standalone context and it works as expected under test (i.e. happy with "" or null into setAsText). However, it doesn't work as expected in web context.

    One thing I note is that, with debug on in Tomcat, the setAsText/getAsText methods on my local copy CNE aren't being called, now this could be a symptom of the problem, but if they aren't being called, then what is.

    Hope someone can shed some light. I've had a dig around but cannot find anything that helps.

    TIA - John

  • #2
    Closed - definite "duh!" moment. I was using the wrong property path. "managerId" should have been "employeeBean.managerId". Though the name mismatch was masked by the reported typeMismatch error that was getting reported because the target field didn't exist.