I have a controller like this:
public class ItemController {
@FXML TextField name;
@FXML TextField description;
private City city = null;
@FXML public void initialize () {
name.textProperty().bind(city.nameProperty());
description.textProperty().bind(city.descriptionProperty());
}
public void searchById(int idCity) {
//get a city by its id, it returns null if not found
city = Backend.getCity(idCity);
}
}
As you see city is initially assigned to null, and searchById assigns it to a new value, I want to create a bind to properties of city when it has a valid value but it's not then set the text properties to empty (perhaps unbinding the fields but I'm not sure) and disable the fields, but I don't have a good idea how to do it, thanks in advance for any help.