r/JavaFX • u/No-Security-7518 • 2d ago
An interesting piece of info I learned about nested controllers
When you nest an fxml layout file inside another with fx:include, the controller of the containing (outer) fxml layout gets a reference to the controller of the included layout with a naming convention of: root+Controller:
This is not very clearly explained in the official docs (here).
I use -ctrl as a naming convention and just included the controller with its original name:
@ FXML
NestedCtrl nestedCtrl
@ FXML
VBox nestedRoot;
Turned out: No. it has to be nestedRootController in this case. Just wanted to share this. Cheers!
10
Upvotes
2
u/tankmatesaquaponics 2d ago
Can you provide a working code snippet we can try ? I didn't know we can officially nest controllers. I always passed the reference explicitly