JavaFX Tabs & Usage of Spring DI
krystofurr opened this issue · 2 comments
Hi,
Not so much an issue but more of a question about how to approach this scenario. I have a project that I'm working on using your library and Spring Boot. I have a controller used for 'Preferences'. In this controller, I use a tabbed interface and each tab has a separate controller for its implementation. I also use .fxml files and load them in for each view.
The issue I'm having is that services fail to autowire into the controller that controls a single tab, . The parent controller that declares the parent tabbed interface has no issue with the service being injected. I believe this is happening because of the way the .fxml for the child tab is loaded b/c it's not using methods defined within the library. I'm loading the file using this method:
tabGeneral.setContent((Node) FXMLLoader.load(getClass().getResource(SceneConfig.SCENE_PATH_PREFERENCES_GENERAL)));
Any ideas? Thanks in advance!
I think I may have figured out a way to remove the call that I was making to inject the .fxml file into the child tab. I found that I was able to nest the .fxml file into its parent file through scene builder ( which took abit to figure out with the child / parent relationship it requires ). This takes care of the loading so I can freely tie a view controller to the child tab controller and autowire spring services. If there is an easier way I'd love to know how. If not, this can be closed. Great library! I love it. Thanks
This is the link I stumbled upon if anyone is having the same issue with nesting .fxml files into another one.
https://stackoverflow.com/questions/36086221/gluon-scenebuilder-8-1-1-problems-using-include-or-import-fxml/36090863
Hi @krystofurr
Thanks and sorry: had no opportunity to read your post earlier.
Your answer seems to me being the right approach, if I got you right.
In general: The tab control should only act as a container while - in the other direction - the single tab should not even be aware being part of a tab.
By this you get isolated components that can be changed, tested, reused without any hassle.
Thanks a lot for posting your solution here.
Will close it now.