CDI - ComboBoxCell - How to reduce 80% of code
The full code and demo jUnit you will find under : BitBucket Repo - RapidPM - Modules - javafx-filtered-tableview
Please use the develop branch and a commit after aec4f95
Today I had a TableView with the following function.
- In one column there was a ComboBoxCell.
- The values of this ComboBox was calculated / loaded at the moment the combobox was used.
- Each ComboBox will have different values based on the context of this row.
The first version was something like this:
and the code called from the controller:
This is to much boilerplate code. So I started to reduce it.
First step was reducing the generics..
This is shorter, but not better...
The solution is the abstract GenericComboBoxCell. (part of the javafx-filtered-tableview module)
Iterating over the columns are now part of the GenericComboBoxCell, and here will be the typesave code.
The developer must extend this class and has to implement the following methods only:
- protected abstract GenericComboBoxCell