JavaFX/CDI Bootstrap – Add On

A few days ago I was writing about the JavaFX/CDI Bootstrap.
There are a few small changings until now.
The final jUnit-Class (extends JavaFXBaseTest ) will implement the method –> testImpl(final Stage stage).
The jUnit-Test will be a manged instance itself.
This is right.. but I forgot to Inject the a few things.
First the JavaFX component that is managed:
The jUnit example (CDIJavaFXBaseApplication001Test, you will find this at cdi-commons-fx) is using the LoginPane.
This is changed from an empty class to the following implementation

Now you have to modify the fxml based on this first version.


At this version you had to declare the controller itself. This can be done later by the init-phase. And the root – element was an pure GridPane.
The new version looks like this:
The root – element is now the self defined class LoginPane and the the controller definition is removed. So you can inject a controller at runtime depending on the ContextResolver.

The jUnit-Test itself changed a little bit. At the first version we used the fxml-Loader to get the LoginPane.. This can now be done by an Inject. (@Inject LoginPane root; )

Kommentare

Beliebte Posts