StringToNumberConverter issue with Long property

Hi Vaadinists,

I recently migrated the Magnolia UI from Vaadin 7.0 to 7.1, and I have the following validation issue when using a TextField bound to a Property of type Long - even if the field is empty: “Could not convert value to Number”.

After digging a bit, here are my findings:

  • The DefaultConverterFactory finds that the Number type is assignable from Long (L106) and returns a StringToNumberConverter. So far so good.
  • However since 7.1, the StringToNumberConverter does a strict comparison between targetType (Long) and model type (Number), and throws a ConversionException.

It seems that either the StringToNumberConverter needs to behave as per type assignability as well, either DefaultConverterFactory should produce a StringToLongConverter, in a similar fashion as for doubles or floats.

Of course I can use my own StringToLongConverter for the time being, in a similar approach as in
this post
, but IMO it deserves a proper fix in Vaadin itself. :slight_smile:



Yeah, StringToNumberConverter is broken. Please see ticket
. The class is actually removed in the 7.2 branch; we should also add a StringToLongConverter at some point.

Question answered, thanks!

Until 7.2 we’ll have our own StringToLongConverter then. :wink: