title: Passing data through Java FX Controller to other View
body: <p>I guess it's a simple question but it was a long day at work and I cant figure the right way out right now. </p>
  
  <p>I have 3 FXML files.</p>
  
  <ul>
  <li><code>Menge.fxml</code></li>
  <li><code>Start.fxml</code></li>
  <li><code>Suche.fxml</code></li>
  </ul>
  
  <p>I'm starting from Main.java as usual</p>
  
  <pre><code>@Override
  public void start(Stage primaryStage) {
      try {
          AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("Start.fxml"));
          Scene scene = new Scene(root);
          scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
          primaryStage.setScene(scene);
          primaryStage.show();
      } catch(Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Inside the <code>MainController</code> I've got the following <code>ActionListener</code></p>
  
  <pre><code>@FXML
  void actionListenerMenge(ActionEvent event) {
      try {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Menge.fxml"));
          Parent root1 = (Parent) fxmlLoader.load();
          Stage stage = new Stage();
          stage.setScene(new Scene(root1));  
          stage.show();
      } catch(Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>So I'm opening the <code>Suche.fxml</code> via the FXMLLoader. 
  Now there is a <code>button</code> inside my Suche-View which opens another scene for where the user should search the specific data record.</p>
  
  <pre><code>@FXML
  void actionListenerSuche(ActionEvent event) {
      try {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Suche.fxml"));
          Parent root1 = (Parent) fxmlLoader.load();
          Stage stage = new Stage();
          stage.setScene(new Scene(root1));  
          stage.show();
      } catch(Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p><code>SucheController</code> where I'm loading the <code>MengeController</code> again via FXMLLoader</p>
  
  <pre><code>FXMLLoader loader = new FXMLLoader(getClass().getResource("Menge.fxml"));
  try {
      Parent root = loader.load();
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  MengeController controller = (MengeController)loader.getController();
  </code></pre>
  
  <p>I want to edit the value inside a <code>TextField</code> @ the <code>MengeController</code> to update the View from my <code>Menge.fxml</code>. But if I do </p>
  
  <p><code>controller.setTextFieldValue("abc")</code> it's not updating. I know it must be because I've loaded the <code>MengeController</code> twice and so there are two instances. But I don't figure out how to load it only once or inject it to update my <code>TextField</code> inside <code>MengeController</code>.</p>