• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dialog with owner: update first window causes @fxml fx:id nodes to be null

 
Fhomas Peeters
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a rather basic JavaFx 2.x pet project which has a main window with stage and a dialog with a new Stage but using the main window as owner.

When the dialog is shown there's a button that imports something to the file system. When this occurs I need to update the controllers and views of the main window and that's where I'm puzzled.

Upon initializing the main window all @FXML injected nodes are available. However when the button in the dialog is clicked, a custom event gets fired which is successfully picked up by the controller of the main window. However when I try to access the @FXML injected nodes they're all null. The controller also has a different memory signature so it's basically a different object.


Dialog caller controller with event handler:



Dialog controller firing the event



I'm rather new in JavaFx and I've never used it professionally.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think your error is in the code you posted.

To get help you will probably need to create an SSCCE.

You may get more help if you post your SSCCE to the Oracle JavaFX forum, which is more active than the JavaRanch JavaFX forum.
 
Fhomas Peeters
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Damien Smith wrote:I don't think your error is in the code you posted.

To get help you will probably need to create an SSCCE.

You may get more help if you post your SSCCE to the Oracle JavaFX forum, which is more active than the JavaRanch JavaFX forum.


You're right. And sorry for not mentioning this, I figured it out.

The problem was that I:
1. violated the MVC pattern by using a controller that extends VBox.
2. I needed to use the correct naming convention for nested controllers.

If you want I'll elaborate further.

But thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic