Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Inconsistent data type when using SimpleType

    We have a SimpleType that we define in our entry point class as currency4Type = new SimpleType("currency4", FieldType.FLOAT). We then add display and edit formatters so fields of that type are handled as decimal numbers with 4 digits to the right of the decimal point. All works well, except for the following scenario.

    One of these fields is in an editable ListGrid that has an EditCompleteHandler. In the onEditComplete code we are using (Float) event.getNewValues().get("theField") to get the new value (we need to know if it was changed). If the user enters a number with digits to the right of the decimal point all is well and the value is returned as a Float. But if the user enters a whole number the value is returned as an Integer and we get a ClassCastException.

    Why the inconsistency in data type?

    #2
    In general, you have to deal with editValues potentially being the wrong type. The user might also have entered "Sam" (not a number at all), in which case you've got a String.

    Comment

    Working...
    X