I have an MVC architecture implemented using JavaFX for querying a medical database. I have two ListViews, one for a database filter, and one for the database fields to be returned. When a user adds a value to the ListView<Filter> an item is usually also added to the ListView<Field>. The ObservableLists for each of these ListViews is encapsulated in a ClientModel for the GUI.
The controller listens for changes to either of these ListViews, (via the model) and submits a query to the database whenever either of them changes. The problem is that when the above "add" occurs, two notifications are sent to the controller - one for each ListView, so I get a double notification for what if effectively one user action.
There are a number of ways to address this architecturally, of course, but I'm looking for a best practice, here. I'm sure others have encountered having the Listeners from multiple UI Controls firing redundantly. Is there an especially applicable pattern to use in JavaFX for controlling these notifications?
Right now I'm thinking of simply adding a "Facade" interface in the ClientModel that encapsulates the two ObservableLists behind an empty ObservableValue, like a SimpleBooleanProperty - which updates the other lists and then call it's own invalidated() method. The Controller would attach an invalidationListener to this Property instead of the other two.
This solution seems a bit kludgy and not very extensible. Does anyone else have a cleaner solution? I'll hack this together and try to post a subset of the code once I have something "working".