0

First off, I am new to the world of JavaFX, so I might lack some basic knowledge, sorry about that. Also, this is the first time I ask a question, so I don't know how to formulate it.

What I want to do is quite basic: I have multiple pages which the user can switch between by pressing next/back. What is the best way to code this so the changes made by the user will be there when he returns to a page? I not only want the TextFields to have the same contents but also the attributes. Note: Every page has its own Controller which implements a common Interface.

I have already tried setting the pages via a loader and using the loader.setController() method and handing over the Controller Object I got from loader.getController() when first creating it, but that doesn't seem to have any effect. Sorry if this is already answered somewhere, I couldn't find it. Thanks in advance to anyone who takes his time to help me!

EDIT: The code with which I change the pages in the ControllerHolder Class

ResourceBundle bundle = FXMLUtil.getResourceBundle();

FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource(
  FXMLUtil.getFXMLPageByIndex(pageNumber)
));
loader.setResources(bundle);

initWizardHolder.getChildren().setAll(
  (Node) loader.load());

currentController = loader.getController();
aw-think
  • 4,723
  • 2
  • 21
  • 42
Crowley Astray
  • 172
  • 1
  • 14
  • 1
    Do you need a wizard like dialog? If so, look here: http://stackoverflow.com/a/19201342/4170073 – aw-think Jul 12 '16 at 11:46
  • @NwDx I am creating a wizard-like dialog, yet it uses FXML and due to my limited JavaFX experience, I cannot translate the example you provided to work with FXML (I will try a bit more though). Regardlessly, thanks for the answer, this very much looks like a possible solution :) – Crowley Astray Jul 12 '16 at 11:59
  • You be able to use the [controlsfx](http://fxexperience.com/controlsfx/) wizard class also in fxml. http://controlsfx.bitbucket.org/org/controlsfx/dialog/Wizard.html – aw-think Jul 12 '16 at 12:04
  • The basic idea should be to keep the root node of each pane, and restore it. If you don't do anything special each root should retain it's controller. Please post the code you use to display pages and switch between them. – Itai Jul 12 '16 at 12:05

0 Answers0