I have designed two MVC structures(not sure if this is the right term)
For a home.fxml and login.fxml.
How do I on successful login change to the home.fxml
view with its controller, as well as saving the current user for the home MVC structure to use.
What I have tried:
I was able to create an EvenHandler in the main.java class and pass that to the LoginView.java class. And the event is hit in LoginView.java the even in main.java would be fired and the scene would switch with this code:
EventHandler<MouseEvent> changeToHome = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
try{
Parent root = FXMLLoader.load(getClass().getResource("Home.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
}catch (IOException err){
}
}
};
But if I do it like this, I can't see a way to pass the authenticated user to the UserController(User MVC)
.
How would I go about doing this?