Is it possible to initialize a controller of an FXML file with parameters? Here is my code:
FXMLLoader loader = new FXMLLoader();
try {
loader.setLocation(this.fichierUIFxml.getURL());
loader.load();
} catch (IOException e) {
e.printStackTrace();
}
Here is my FXML code:
<VBox xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.inexa.fix.ui.view.controller.UIController" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1408.0" stylesheets="style/ui.css" style="-fx-background-color: white;">
...
</VBox>
Here is the controller I want to initialize:
public class UIController {
public ProgressIndicator progressIndicator;
@Value("classpath:ordre.fxml")
Resource fichierOrdreFxml;
private AuthentificationController authentificationController;
public UIController(VMLogiqueAuthentification vmLogiqueAuthentification) {
this.authentificationController = new AuthentificationController(vmLogiqueAuthentification);
}
@FXML
public void initialize() {
...
}
}