Closed svedie closed 5 years ago
Hi,
this is already possible. There are overloaded field
methods that are taking an additional argument for the default value. See this example:
public StringProperty nameProperty() {
return wrapper.field("name", MyObject::getName, MyObject:setName, "default value here");
}
For your example with an observable list it would be:
ObservableList<String> numberProperty() {
return wrapper.field("number", MyObject::getNummer, MyObject::setNummer, new ArrayList<>());
}
Thanks!
I missed this one method :(
When I define a
ModelWrapper
in theViewModel
:ModelWrapper<MyObject> wrapper = new ModelWrapper<>();
all values of
MyObject
are initialized withnull
.Now, when I use the
wrapper
to retreive the values and they are null, anNullPointerException
is thrown.This definition of an observable list property:
throws an
NullPointerException
if I use it to initialize anComboBox
or anListView
.It would be helpfull, if one could define an default value in the
ModelWrapper
for the getter method. If there is no default value is defined, then the behavior is as now implemented.