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.

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Spelling error report

The following text will be sent to our editors: