JavaFX Gluon Ignite Guice Inject Controller

I had to inject a whole controller into another controller with the guice implementation of gluon ignite. I will show an approach doing so. This is applicable if you have set the controller id in your fxml. Otherwise this snipped requires slightly modifications. I assume you have ignite already running and injecting stuff already but facing the “inject a controller for me” problem.

Create a new provider for your controller you want to inject and register it. If you decide to create this as inner class of your module you have to use a static inner class.

Use it to inject

You are done! Use the injected controller as usual.

Leave a Reply

Your email address will not be published. Required fields are marked *