Proposal for improving nested controller interaction in JavaFX 2.2

Greg Brown greg.x.brown at
Wed Feb 22 07:51:14 PST 2012

> now that I think about it, I wonder if it might make more sense to map nested controller instances directly to including controller fields, like we do with namespace values.

FYI, I have prototyped this and I think it works well. Here's what my primary scene controller looks like now:

public class PrimarySceneController extends Controller {
    @FXML private Scene scene; // the scene associated with this controller
    @FXML private Scene dialogScene; // the dialog scene
    @FXML private DialogSceneController dialogSceneController; // the dialog scene's controller
    @FXML private ChoiceBox<Contact> contactChoiceBox; // choice box of contacts to edit
    protected void handleEditButtonAction() {
        // Get the selected contact
        Contact contact = contactChoiceBox.getSelectionModel().getSelectedItem();
        // Populate the dialog with the contact information
        // Show the dialog
        Stage dialogStage = new Stage();


The controller for the include is automatically mapped by the loader to the dialogSceneController field, so it is typed and readily available in my button's action handler.


More information about the openjfx-dev mailing list