initialLayout

initialLayout displays default content in the main view when no other view is open.

XML Element

initialLayout

Java Class

VerticalLayout

Basics

initialLayout is a nested element of the appLayout component.

An example of defining initialLayout in main-view.xml:

<mainView xmlns="http://jmix.io/schema/flowui/main-view"
          title="msg://MainView.title">
    <appLayout>
        <navigationBar .../>
        <drawerLayout .../>
        <initialLayout>
            <image id="urlImage"
                   resource="https://www.jmix.io/uploads/framework_image_9efadbc372.svg"
                   width="100%"
                   height="100%"/>
        </initialLayout>
    </appLayout>
</mainView>

In XML, the root initialLayout element is loaded as a VerticalLayout.

Alternatively, use the StandardMainView Java API to access or replace the initial layout:

  • getInitialLayout() returns the root component of the initial layout.

  • setInitialLayout() replaces the initial layout component.

Components inside initialLayout can be injected into the MainView, for example:

@ViewComponent
private JmixImage<Object> urlImage;
@Autowired
private Notifications notifications;

@Subscribe
public void onInit(final InitEvent event) {
    urlImage.setSrc("https://www.jmix.io/uploads/framework_image_9efadbc372.svg");
    urlImage.setWidth("100%");
    urlImage.setHeight("100%");
}

@Subscribe(id = "urlImage", subject = "singleClickListener")
public void onUrlImageClick(final ClickEvent<JmixImage<?>> event) {
    Notification.show("Clicked!");
}

Attributes

initialLayout supports common component attributes and the layout attributes documented for vbox.

Handlers

Name Description

AttachEvent

Fires when the layout is attached to the UI.

ClickEvent

Fires when the layout is clicked.

DetachEvent

Fires when the layout is detached from the UI.

Elements

initialLayout can contain components and layouts displayed as the main view’s initial content.