troubleshooting Question

Javafx passing parameters before loading the fxml loader

Avatar of Panos
PanosFlag for Germany asked on
Java
5 Comments1 Solution12 ViewsLast Modified:
Hi experts . I m trying to pass parameters to fxml loader before loading the controller to define the gui how it should look like and what it should include a.s.o.
I have a main container and after clicking on buttons this container is loading the data from fxml. like this:
@FXML
private StackPane acContent;
@FXML
private void btnSupplierOnClick(ActionEvent event) throws IOException {
  FXMLLoader fxmlLoader = new FXMLLoader();
  fxmlLoader.load(getClass().getResource(/view/application/supplier/ViewSupplierList.fxml").openStream());
  AnchorPane acPane = fxmlLoader.getRoot();
  ViewSupplierListController supplierListController = fxmlLoader.getController();
  // Passing data to the supplierListController
  supplierListController.setData(userNameMedia,rootPane,acContent,acMain);
  acContent.getChildren().clear();
  acContent.getChildren().add(acPane);
}
With the setData function i m passing values to the controller but this happens after the controller has been loaded.
After googling i found a solution here (1. Create a controller instance manually) but i didn t get it to work.
Any help to solve my problem?
Thank you in advance.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros