JavaFx: not String null values and binding

Tom Schindl tom.schindl at
Wed Jun 10 12:15:07 UTC 2015

So if the value is null-able IntegerProperty is not the right type! You
need to use a ObjectProperty<Integer> but this is more of a user forum


On 10.06.15 13:56, Александр Свиридов wrote:
> 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
> nameTextField.textProperty().bindBidirectional(adapter.getNameProperty());
> //the following line throws exception Integer id=null
> idTextField.textProperty().bindBidirectional(adapter.getIdProperty(),newNumberStringConverter());
> 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
> test.setId(0);
> idTextField.textProperty().bindBidirectional(adapter.getIdProperty(),newNumberStringConverter());
> 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.

Thomas Schindl, CTO EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7, A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck

More information about the openjfx-dev mailing list