initialLayout
The initialLayout
component is a layout that will be displayed when no views are opened in the main view. This component can be useful when you need to show some default content, such as a logo or dashboard, before any other views are opened.
-
XML element:
initialLayout
Basics
initialLayout
is a nested element of the appLayout
component.
To add a nested initialLayout element in Jmix Studio, select the appLayout element in the main view descriptor XML or in the Jmix UI structure panel and click on the Add→InitialLayout button in the Jmix UI inspector panel.
|
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>
When added in XML, the root <initialLayout>
element effectively is VerticalLayout.
Alternatively, the StandardMainView
Java API can be used to set/get the initial layout:
-
getInitialLayout()
- returns the root component of the initial layout. -
setInitialLayout()
- sets a component that will be the initial layout.
Components inside initialLayout
can be injected into the MainView
, for example:
@ViewComponent
private JmixImage<Object> urlImage;
@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
id - alignItems - boxSizing - classNames - css - enabled - expand - height - justifyContent - margin - maxHeight - maxWidth - minHeight - minWidth - padding - spacing - themeNames - width
Handlers
To generate a handler stub in Jmix Studio, use the Handlers tab of the Jmix UI inspector panel or the Generate Handler action available in the top panel of the view class and through the Code → Generate menu (Alt+Insert / Cmd+N). |