I have a PropertyBusinessObject Vehicle Object defined with:

``` 
public final LongProperty<Vehicle> id = new LongProperty<>("id", new 
Long(-1)); 
public final IntProperty<Vehicle> height = new IntProperty<>("height");
public final IntProperty<Vehicle> length = new IntProperty<>("length");
public final IntProperty<Vehicle> width = new IntProperty<>("width");
public final IntProperty<Vehicle> weight = new IntProperty<>("weight");

...

public Vehicle() {
id.setNullable(true);
height.setNullable(true);
length.setNullable(true);
width.setNullable(true);
weight.setNullable(true);
}
```

The problem I have is that, when I want to internalize one of this stored 
Vehicle object with a null IntProperty, I end up with an error like that:

```
java.lang.NullPointerException: height can't be null
at com.codename1.properties.NumericProperty.set(NumericProperty.java:87)
at 
com.codename1.properties.MyPropertyIndex$1.internalize(MyPropertyIndex.java:285)
at com.codename1.io.Util.readObject(Util.java:693)
at com.codename1.io.Util.readObject(Util.java:664)
at com.codename1.io.Storage.readObject(Storage.java:261)
```

I don't realy know how to solve this issue (exept by forcing my IntProperty 
to have a default value, like I did for `id`. But I would like to keep it 
null if possible as I also bind these properties to ui and a null 
Intproperty value would directly convert to an empty String in a TextField 
whereas a default -1 of 0 value for example, would be directly displayed as 
it is). 
I assume that the internalization process don't call the Vehicle() default 
constructor, which is why my setNullable(true) are not called in this case. 
Is there another way I could define my IntProperty as nonNullable to avoid 
this?

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/221be279-6546-4a34-9089-0759cb1d70da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to