I modify a ListView
with the results from a database search in order to use that selection to make another DB request later on.
I want to get the field value of that ListView
. What method can I use for that?
I just thought I can also add an event to the onclick
and keep it on an attribute for the controller. Is that acceptable too?
Say with list view like this:
ListView<String> listView =new ListView<String>();
Getting selected element from ListView:
listView.getSelectionModel().getSelectedItem();
Tracking (Listening) the changes in list view selection:
listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
System.out.println("ListView selection changed from oldValue = "
+ oldValue + " to newValue = " + newValue);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With