title: How to get data from multiple Nested FXMLs And call methods on their controllers
body: <p>Here's what my project looks like:</p>
  
  <p><code>Main.FXML</code></p>
  
  <ul>
  <li>AnchorPane
  
  <ul>
  <li>VBox   [Egg Container] id="_eggContainer"</li>
  <li>Button [Add Egg] --> Adds an eggview to _eggContainer</li>
  <li>Button [Print Eggs] --> prints all eggs' properites</li>
  <li>Button [Break Eggs] --> Calls break method on each egg</li>
  </ul></li>
  </ul>
  
  <p><code>EggView.FXML</code></p>
  
  <ul>
  <li>HBox
  
  <ul>
  <li>Label: [Egg ID] Should be incremented each time an eggView is instantiated</li>
  <li>TextField: [Egg Color]</li>
  </ul></li>
  </ul>
  
  <p><code>MainController.java</code></p>
  
  <pre><code>public class MainController implements Initializable {   
  
      /***CONTROLS***/
      @FXML private VBox   _eggsContainer;
      @FXML private Button _btnAddEgg;
      @FXML private Button _btnPrintEggs;
      @FXML private Button _btnBreakEggs;
  
      @Override
      public void initialize(URL location, ResourceBundle resources) {
          _btnAddEgg.setOnMouseClicked(e -&gt; {
              doAddEgg();
          });
          _btnPrintEggs.setOnMouseClicked(e -&gt; {
              doPrintAllEggs();
          });
          _btnBreakEggs.setOnMouseClicked(e -&gt; {
              doBreakAllEggs();
          });
      }
  
      // Add an egg to _eggsContainer
      private void doAddEgg() {
          HBox eggControl = null;
          try {
              eggControl = FXMLLoader.load(getClass().getResource("EggView.fxml"));
          } catch (IOException e) {
              e.printStackTrace();
          }
          _eggsContainer.getChildren().add(eggControl);
      }
  
      private void doPrintAllEggs() {
          // prints ID and Color of each egg in _eggsContainer
      }
  
      private void doBreakAllEggs() {
          // call the break method in EggController controller on each egg
      }
  }
  </code></pre>
  
  <p><code>EggController.java</code></p>
  
  <pre><code>public class EggController {
  
      /***CONTROLS***/
      @FXML private Label _eggID;
      @FXML private TextField _eggColor;
  
      public void doBreakEgg() {
          // TODO: Break Egg
      }
  
      /****************************************************************
       **********                  ACCESSORS               ************
       ****************************************************************/
      public String getEggID() {
          return _eggID.getText();
      }
  
      public String setEggID(String id) {
          return _eggID.setText(id);
      }
  
      public String getEggColor() {
          return _eggColor.getText();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Now how can i access each eggs data and methods from my main controller? Without having to give each egg an ID and reference it in MainController.</p>