StringBinding and null

Scott Palmer swpalmer at gmail.com
Tue Jan 19 16:09:58 UTC 2016


So I just discovered that:

ObjectProperty<String> objectPropertyString = new
SimpleObjectProperty<>(null);
StringBinding stringBinding = objectPropertyString.asString();

stringBinding.get() == null --> FALSE

stringBinding.get().equals("null") --> TRUE


I care because this fails to do what I want:

Button okayButton;
ComboBox<String> combo;
//...
BooleanBinding dontHaveValue =
Bindings.isEmpty(combo.valueProperty().asString());
okayButton.disableProperty().bind(dontHaveValue);

The behaviour is understandable and obviously too late to change even if we
wanted to (which we probably don't).  But I wonder if StringBinding can be
tweaked so you can enable the pass through of null if you choose to?

If others agree I will open an issue.

Scott


More information about the openjfx-dev mailing list