RFR: 8279640: ListView with null SelectionModel/FocusModel throws NPE

Marius Hanl mhanl at openjdk.java.net
Tue Jan 11 08:18:26 UTC 2022


On Sat, 8 Jan 2022 14:32:30 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

> Same goes for the selection model; if set to `null` it should not allow any kind of selection, which again seems best achieved by installing a model that ignores all such actions and always returns empty values.

We had a similar discussion on https://github.com/openjdk/jfx/pull/557. We came to the conclusion that we allow null as a selection or focusmodel and don't set a noop selection model or something of this kind.

The biggest problem with this is the following example:
I as a developer set the selection model to null via `setSelectionModel(null)`. Now if the code silently set the selection model to an empty noop selection model, we won't get null when calling `getSelectionModel()`, which a developer would expect.

Also from a look of the code, even if we use a noop focus model, we would still the focus because of the `anchor` stuff, which is set in the `ListViewBehaviour`. 
If we do a null check and fast return like now, they won't be set -> there are not visible. So it might not even fix our problem but makes even more.

-------------

PR: https://git.openjdk.java.net/jfx/pull/711


More information about the openjfx-dev mailing list