I want to load new FXML file with some parameters from the other Controller Files

拟墨画扇 提交于 2019-12-02 13:23:37

The exception says that the FXMLLoader cannot access to your ManageTemplateChildController class itself or to its fields/methods through reflection. Make your class public. Add @FXML annotation to private fields which are defined in FXML file as "fx:id", or alternatively make these fields public without adding @FXML annotation.

The link that you have provided has everything in it. It is one of the best answers for those who have doubts on How to pass data between Controllers and an answer to your question as well !

But, in your case, I would suggest to use Binding inside of passing parameters ! You can have a id in your ChildController and you can just bind it to the MainController's id. So that the value of id is automatically passed between the controllers

You can have a look at the following URL for a better understanding or if you can show, how you getting the id in MainController, may be I can help you with some code !

http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm

http://www.drdobbs.com/jvm/javafx-20-binding/231903245

EDIT - To load controller from FXML

@FXML
private void handleButtonAction(ActionEvent event) throws IOException 
{
         //Instead of making a reference from the FXMLLoader, you are creating a new Object
         //ManageTemplateChildController m = new ManageTemplateChildController();
         //try using
         FXMLLoader loader = new FXMLLoader(getClass().getResource("ManageTemplateChild.fxml"));
         ManageTemplateChildController controller = 
                          loader.<ManageTemplateChildController>getController();
         //where loader is the FXMLLoader for you second FXML
         m.redirecthome(stage,Finalvaluetablerow);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!