title: Access actions in embed FXML
body: <p>Structure of my application is approximately like this MainApplication->SuperFXMLController->ChildFXMLController. Every ChildFXML has a button to add one more child element to the GridPane in SuperFXML I have defined buttonHandler method in ChildFXMLController but the action itself should be happening in SuperFXMLController (add new row in grid). The question is how to handle the action from SuperFXMLController? </p>
  
  <p>Here some code details:
  AddLogRecordController.java (so called "SuperFXMLController"):</p>
  
  <pre><code>@FXML
  private void initialize() throws IOException {
  rowIndex = 0;
  
      FXMLLoader loader = new FXMLLoader(getClass().getResource("RecordGrid.fxml"));
  
      mainGrid.add(loader.load(), 0, rowIndex++);
      RecordGridController controller = (RecordGridController) loader.getController();
      controller.setSuperController(this);
  }
  ...
  public void addRowHandle() {
      try {
          FXMLLoader loader = new FXMLLoader(getClass().getResource("RecordGrid.fxml"));
  
          mainGrid.getChildren().add(loader.load());
          RecordGridController controller = loader.getController();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>"RecordGridController" referred as "ChildFXMLController":</p>
  
  <pre><code>private AddLogRecordController superController;
  ...
  public void setSuperController(AddLogRecordController addLogRecordControllerClass) {
      this.superController = addLogRecordControllerClass;
  }
  ...
  @FXML
  private void addRowHandler() {
      superController.addRowHandle();
  }
  </code></pre>
  
  <p>And this is result window where the section surrounded by red is a child fxml that should be duplicated as many times as button Add to QSO pressed:
  <a href="https://i.stack.imgur.com/7doxq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7doxq.png" alt="And this is result window where the section surrounded by red is a child fxml that should be duplicated as many times as button Add to QSO pressed"></a></p>