• load fxml by different pattern (convention over configuration)
  • CDI powered ViewController (FXMLLoader, FXMLLoaderProvider)
  • ViewController rootPane is bound to fxml root element


ViewController extends FxmlLoading trait. FxmlLoading provide the

getController[T <: ViewController](fxml: String = "")

method. The package path of the controller is the default fxml directory. [name]Controller is converted to [name].fxml (WorkspaceController -> Workspace.fxml).

package controller class MainViewController extends ViewController with LazyLogging { // workspaces lazy val workspaceController = getController[WorkspaceController]() // navigation lazy val defaultNavigationController = getController[DefaultNavigationController]() }

WorkspaceController fxml must be saved at /controller/Workspace.fxml.

Different FXML-Path lookup pattern


In case of mixing this pattern, FXML-Path is resolved from Pattern 1 to 3

Pattern 1: Define path in getController:

  lazy val controller = 

@FxmlLoader(path=“/fxml/widget/Person.fxml”) class PersonController extends AbstractViewController { WorkspaceController fxml must be saved at /fxml/special/path/special_name.fxml.

Pattern 2: Define path in FxmlLoader Annotation:

class PersonController extends AbstractViewController {
  // some stuff ...

WorkspaceController fxml must be saved at /fxml/widget/Person.fxml.

Pattern 3: Define path in application.conf:


WorkspaceController fxml must be saved at /fxml/Workspace.fxml.