[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Proposal for improving nested controller interaction in JavaFX 2.2
From:       greg.x.brown () oracle ! com (Greg Brown)
Date:       2012-02-22 15:51:14
Message-ID: 2DEE5078-C9D3-49C4-9C3E-8F251D4F6C96 () oracle ! com
[Download RAW message or body]

> 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  
    ?
    
    @FXML
    protected void handleEditButtonAction() {
        // Get the selected contact
        Contact contact = contactChoiceBox.getSelectionModel().getSelectedItem();
        
        // Populate the dialog with the contact information
        dialogSceneController.setContact(contact);
        
        // Show the dialog
        Stage dialogStage = new Stage();
        dialogStage.setScene(dialogScene);
        dialogStage.initOwner(scene.getWindow());
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        dialogStage.show();

        ?
    }
}

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.

G


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic