Loosely coupled

A JacpFX application has a hierarchical structure composed of a Workbench, Perspective(s) and Component(s). All references to them are handled by ID's inside the component annotation of the parent component.

loosely coupled

Example Workbench annotation, referencing two perspectives:
@Workbench(id = "id1", name = "workbench",
        perspectives = {
                BaseConfiguration.PERSPECTIVETWO,
                BaseConfiguration.PERSPECTIVEONE
        })

Example Perspective annotation, referencing two Components:
@Perspective(id = BaseConfiguration.PERSPECTIVEONE, name = "contactPerspective",
        components = {
            BaseConfiguration.COMPONENTONE, 
            BaseConfiguration.COMPONENT_TWO
            },
        resourceBundleLocation = "bundles.languageBundle")

Perspectives and Components are resolved by Component scanning on application startup. To exchange a Component reference in a Perspective, simply remove the "old" Component ID and add the new one.

Loosely coupled view rendering

Perspectives are defining the layout structure of your view. You can define "render-targets" in your Perspective by ID, to mark areas where Component views should be rendered. Each Component of a Perspective can register to a specific "render-target", so the resulting view of a Component will be included at that specific area. The "render-target" of a Component can also be changed at runtime, so a Component view can be moved from one area in Perspective to an other.

Register targets in a perspective ###

@Perspective(id = BaseConfig.ID, name = "p1",components = {…},
        viewLocation = "/fxml/ExamplePerspective.fxml")
public class ExampleFXMLPerspective implements FXPerspective {
    @FXML
    private HBox contentTop;
    @FXML
    private BorderPane contentBottom;
    
    @PostConstruct
    public void onStartPerspective(final PerspectiveLayout perspectiveLayout, final FXComponentLayout layout,
                                   final ResourceBundle resourceBundle) {
        // register left menu
     perspectiveLayout.registerTargetLayoutComponent(PerspectiveIds.TARGET_CONTAINER_TOP, contentTop);
        // register main content
     perspectiveLayout.registerTargetLayoutComponent(PerspectiveIds.TARGET_CONTAINER_BOTTOM, contentBottom);

    }
} 


Component example:

@DeclarativeView(id = ComponentIds.COMPONENT_ONE,
        name = "SimpleView",
        active = true,
        resourceBundleLocation = "bundles.languageBundle",
        initialTargetLayoutId = PerspectiveIds.TARGET_CONTAINER_TOP,
        viewLocation = "/fxml/ComponentOne.fxml")
public class ComponentOne implements FXComponent {

...
}

shadow