ObservableList vs Models
Mark Claassen
markclaassenx at gmail.com
Wed Oct 17 13:01:51 PDT 2012
I really like the promise of the ObservableList, but am a bit wary of the
current implementation.
We have several instances in our code where we rely on unique models
wrapping the same data. We can have a large list of items, and show them
in a combo box, and list, and a table. Generally, only one of these is
visible at a given time, but having a single backing list is very handy.
Further, each list can be independently sorted and filtered via a decorator
construct in the model.
By tweaking the underlying list object (so it fires events) and model (so
that it listens to events), we accomplished something similar to an
ObservableList:
* Changes to the underlying list fires events to the models
* Models could then respond as appropriate, add/deleting/changing items as
necessary...perhaps triggering the view to re-sort the decorator as
necessary
However, different from ObservableList, we can manage the
side-effects...not sorting and filtering all models in an identical fashion.
Is there a mechanism to do this in JavaFX? The Swing methodology seemed a
nice way to do it. With ObservableLists, it seems that in the end, I don't
get much. The more common / trivial case is handled. However, in the case
of a our application, I will need to
* Make several ObservableLists, one for each control
* Manage the synchronization between these lists programmaticly by myself.
Am I missing something? Is there a way to have an ObservableList
listening to another ObservableList, so that list #2 can notice the updates
without forcing the sort order and filtering on list #1? Or am I just
going to end up having to cut through extra/different layers of abstraction
to re-implement what I had in Swing.
Mark
More information about the openjfx-dev
mailing list