Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8102463

Improve access to sub-controllers in FXML

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Subcomponent:

      Description

      It is not currently very easy to access sub-controllers from a root controller. This makes it difficult to use a controller to open and populate a dialog, for example.

      The proposed solution is to map nested controller instances directly to including controller fields, like we currently do with namespace values. For example, if a main FXML document looks like this:

      <VBox fx:controller="com.foo.MyMainController">
       ...
       <fx:include fx:id="myInclude" source="my_include.fxml"/>
       ...
      </VBox>

      The document's controller might look like this (the root element of the include is assumed to be a HBox with a controller of type MyIncludeController):

      public class MyMainController extends Controller {
         @FXML private HBox myInclude;
         @FXML private MyIncludeController myIncludeController;

         ...
      }

      When initialize() is called, myInclude would contain the root element from "my_include.fxml", and myIncludeController would contain the include's controller, allowing the including code to easily interact with the included controller.


        Attachments

          Activity

            People

            • Assignee:
              gkbrown Greg Brown (Inactive)
              Reporter:
              gkbrown Greg Brown (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: