I am trying to transfer an object from Controller A to Controller B, but whenever I try, it sets my object as null. I have an object of called user in Controller B. Also in Controller B I have a method called public void setUser(). The full method is: public void setUser(User user) { this.user = user; In Controller A, I do the following:
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("B.fxml"));
loader.load();
ControllerB ctrl = loader.getController();
cntrl.setUser(user);
In Controller B I have this:
SalesAsso user;
public void setUser(SalesAsso user) {
this.user = user;
}
my controller B object is not null, but it still doesn't set my user as "user". I run the code, it It runs fine. but then when I try to manipulate that salesAsso object, the object is null and It won't let me do anything with it.