-
1. Re: Binder.setModel with InitialState.FROM_MODEL causes NPE in Convert
csa Feb 14, 2013 12:36 PM (in response to shadogray)Hi Thomas,
It does seem this was implemented too defensively. I pushed a change that allows for null values for all types in the default conversion utility. If you update your 2.2.1-SNAPSHOTs you should be able to use the change immediately.
Cheers,
Christian
-
2. Re: Binder.setModel with InitialState.FROM_MODEL causes NPE in Convert
shadogray Feb 14, 2013 2:45 PM (in response to csa)Hi Christian,
sorry for molesting :-)
two more questions:
- is there a specific reason to map null String to ""
of course it would be unpleasant to change if users already rely of implicit Null mapping
- Class identity check does not account for inheritance
if (toType.equals(o.getClass())) {
return o;
}
I would propose to use
if (toType.isAssignableFrom(o.getClass()))
Thanks,
Thomas
-
3. Re: Binder.setModel with InitialState.FROM_MODEL causes NPE in Convert
csa Feb 15, 2013 11:09 AM (in response to shadogray)Hi Thomas,
I don't think isAssignableFrom is part of GWT's JRE emulation library. We could work around that but I am not sure what the use case would be here. Looking at all HasValue<T> implementations in the default GWT widget set we find: String, Date, Boolean, Double, Integer, and Long. The Convert utility class is only used for simple built-in conversions using those types. Anything more complicated requires a custom converter. Is there a specific built-in converstion you are missing? If so, we should add a conversion rule for it.
To your first question: I did some git archeology and found the commit that introducd the null to "" mapping for Strings. You are right, it looks like this conversion is no longer required. However, it doesn't seem to make a difference as textBox.setValue(null) will cause textBox.getValue() to return an empty string. So, at least in our way it's symmetric. Does this cause problems on your end? If so, it looks like we can change that.
Cheers,
Christian
-
4. Re: Binder.setModel with InitialState.FROM_MODEL causes NPE in Convert
shadogray Feb 16, 2013 4:01 AM (in response to csa)Hi Christian,
thank you for the detailed explanation - isAssignableFrom: I totally forgot, where all this is happening :-)
For completeness I would propose to add BigDecimal and BigInteger, which both are supported by GWT JRE:
else if (toType.equals(BigDecimal.class)) {
return new BigDecimal((String) o);
}
else if (toType.equals(BigInteger.class)) {
return new BigInteger((String) o);
}
WDYT?
for Strings: this is really an old PITA, if you take into account, that in the end the server's DB (like Oracle) will turn "" into NULL, effectively destroying any effort on differentiating.
Best regards,
Thomas
-
5. Re: Binder.setModel with InitialState.FROM_MODEL causes NPE in Convert
csa Feb 16, 2013 1:15 PM (in response to shadogray)Hi,
Yes, good idea! We will add built-in conversions for BigDecimal and BigInteger.
Thanks,
Christian