Please how to share object User between Controllers? I have a TabPanelController. In initialization send to other controllers Data with object User. Its OK, but I cant acces to this object before stage shown.
Its possible acces to Stage in initialize method in controller, when controller is loaded before Stage? Or how handle onWindowShow in loader (When windows show, object User was filled)?
@FXML
private ActionController panelActionController;
@FXML
private StoreController panelStoreController;
@FXML
private ProfilesController panelProfilesController;
@FXML
private UsersController panelUsersController;
@FXML
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
Platform.runLater(new Runnable() {
@Override
public void run() {
menuUserInfo.setText(" " + loggedInUser.getName() + " " +
loggedInUser.getForname() + " (" + loggedInUser.getLogin() + ")");
menuUserInfo.setUserData(loggedInUser);
panelActionController.setLoggedUser(loggedInUser);
panelStoreController.setLoggedUser(loggedInUser);
panelProfilesController.setLoggedUser(loggedInUser);
panelUsersController.setLoggedUser(loggedInUser);
}
});
}
In panelActionController
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
System.out.println(loggedInUser); // NULL..
}
When i press any button in stage, loggedUser is not null. But i need set buttons, textfields by user role (Admin, User) during initialization.