DataFX Controller API
The DataFX team will show some cool new APIs at JavaOne this year. Johan has written a post about writeback support in the new DataFX version some days ago. Today I will give a short preview to another part of the new DataFX APIs.
The Controller API
The base of the API is the inversion of control for JavaFX controllers. The API offers the annotation
FXMLController that can be assigned to any controller class. By using this annotation you can define the FXML-View that should be used by this controller. If you don‘t define the name of the FXML-File the API will try to find the view by using a convention over configuration approach. By doing so you do not need to add Java class information in your FXML file. You can use all default FXML annotations that are defined by JavaFX. By doing so you can inject all your nodes that are defined in the fxml-file in the controller by simply adding the
@FXML annotation. Additionally you can use the
@PostConstruct annotation. A simple Controller that is created by this API can look like this one:
To load the view and the controller DataFX-Controller offers a simple HelperClass called
ViewFactory. This is the default entry point to the complete DataFX-Controller API. You can create a view and controller by using this class:
The FXML-file that is used by this controller can look like this one:
If you want to see more code check out the DataFX 2.0 repository at bitbucket.
We will provide more samples and tutorials later, and you are very welcome to join us at JavaOne (CON3202, Wednesday Sep 25, 08:30 am, Hilton - Plaza B).