ScreenSettingsFacet

ScreenSettingsFacet is a facet that saves the settings that the user has set for visual components.

Component’s XML-name: screenSettings.

Basics

ScreenSettingsFacet is defined in the facets element of the screen XML descriptor.

To enable screen settings saving for all components on the screen, you can set the auto attribute to true:

<facets>
    <screenSettings auto="true"/>
</facets>

You can enable settings saving only for some components. To do that, declare these components explicitly:

<facets>
    <screenSettings id="settingsFacet">
        <components>
            <component id="carsTable"/>
        </components>
    </screenSettings>
</facets>
<layout expand="carsTable" spacing="true">
    <groupTable id="carsTable"
                width="100%"
                dataContainer="carsDc">
        <!-- ... -->
    </groupTable>
</layout>

If necessary, you can disable settings saving for a particular component. To do that, set its enable attribute to false:

<facets>
    <screenSettings id="settingsFacet" auto="true">
        <components>
            <component id="carsTable" enable="false"/>
        </components>
    </screenSettings>
</facets>
<layout expand="carsTable" spacing="true">
    <groupTable id="carsTable"
                width="100%"
                dataContainer="carsDc">
        <!-- ... -->
    </groupTable>
</layout>

Events and Handlers

To generate a handler stub in Jmix Studio, select the facet in the screen descriptor XML or in the Jmix UI hierarchy panel and use the Handlers tab of the Jmix UI inspector panel.

Alternatively, you can use the Generate Handler button in the top panel of the screen controller.

You can use ScreenSettingsFacet delegates to intercept the screen settings lifecycle.

ApplySettingsDelegate

This handler allows you to save the states of the components on AfterShowEvent.

@Autowired
private ScreenSettingsFacet settingsFacet;
@Autowired
private GroupTable<Car> carsTable;

@Install(to = "settingsFacet", subject = "applySettingsDelegate")
private void settingsFacetApplySettingsDelegate(ScreenSettingsFacet.SettingsContext settingsContext) {
    settingsContext.getScreenSettings()
            .getBoolean("carsTable", "visibility")
            .ifPresent(visibility -> carsTable.setVisible(visibility));

    settingsFacet.applySettings();
}

Programmatic usage: call the setApplySettingsDelegate() component method.

ApplyDataLoadingSettingsDelegate

This handler allows you to save the states of the components on BeforeShowEvent.

Programmatic usage: call the setApplyDataLoadingSettingsDelegate() component method.

SaveSettingsDelegate

This handler allows you to save the states of the components on AfterDetachEvent.

Programmatic usage: call the setSaveSettingsDelegate() component method.

All XML Attributes

You can view and edit attributes applicable to the facet using the Jmix UI inspector panel of the Studio’s Screen Designer.

auto - id