JavaFx: not String null values and binding

Александр Свиридов ooo_saturn7 at
Wed Jun 10 11:56:36 UTC 2015

I have a POJO class Test that has Integer and String fields (all of them can be null). And I have javafx form with TextFields. To bind Test fields to text fields I use adapter. Now I create an instance of Test (all fields will be null)
Test test=new Test();
TestAdapter adapter=newTestAdapter(test);
//the following line works, although String name=null
//the following line throws exception Integer id=null
This is the exception I get:
>Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at$get$38( at Method) at at javafx.beans.binding.IntegerExpression.getValue( at javafx.beans.binding.IntegerExpression.getValue( at com.sun.javafx.binding.BidirectionalBinding.bind( at javafx.beans.binding.Bindings.bindBidirectional( at
Everything works ok if I do this way
However, you can imagine how ugly this solution is - I loose all the abilities of null value and for my CRUD application it is death. Please, help me to understand how to work with Integer(and Others?) null values with bindings and adapters.

Александр Свиридов

More information about the openjfx-dev mailing list