EditorScreenFacet

EditorScreenFacet is essentially a ScreenFacet with an extended set of options for opening entity edit screens.

Component’s XML-name: editorScreen.

Attributes

In addition to the attributes of ScreenFacet, EditorScreenFacet has the following own attributes:

  • addFirst - defines whether a new item will be added to the beginning or the end of the collection. It affects only standalone containers; for nested containers, new items are always added to the end.

  • container - sets a CollectionContainer. The container is updated after the screen is committed. If the container is nested, the framework automatically initializes the reference to the parent entity and sets up data context for editing compositions.

  • editMode - sets the screen edit mode, corresponds to the EditMode enum:

    • CREATE - to create a new entity instance.

    • EDIT - to edit an existing one.

  • entityClass - the full name of an entity class.

  • field - sets the EntityPicker component id. The framework sets the committed entity to the field after a successful editor commit if the field is set.

  • listComponent - sets the list component id. The component is used to get the container if it is not set. Usually, the list component is a Table or DataGrid displaying the list of entities.

Usage example:

<window xmlns="http://jmix.io/schema/ui/window"
        caption="msg://editorScreenFacetScreen.caption">
    <data readOnly="true">
        <collection id="departmentsDc"
                    class="ui.ex1.entity.Department">
            <fetchPlan extends="_base">
                <property name="employee" fetchPlan="_base"/>
            </fetchPlan>
            <loader id="departmentsDl">
                <query>
                    <![CDATA[select e from uiex1_Department e]]>
                </query>
            </loader>
        </collection>
    </data>
    <facets>
        <editorScreen id="editorScreen"
                      editMode="CREATE"
                      entityClass="ui.ex1.entity.Customer"
                      onButton="openEditBtn"
                      addFirst="true">
        </editorScreen>
        <dataLoadCoordinator auto="true"/>
        <screenSettings id="settingsFacet" auto="true"/>
    </facets>
    <layout>
        <button id="openEditBtn"
                caption="Open an editor screen"
                width="100%"/>
    </layout>
</window>

Events and Handlers

To generate a handler stub in Jmix Studio, select the facet in the screen descriptor XML or in the Component Hierarchy panel and use the Handlers tab of the Component Inspector panel.

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

AfterCloseEvent

AfterCloseEvent is sent after the screen configured by the facet is closed. See AfterCloseEvent for details.

AfterShowEvent

AfterShowEvent is sent after the screen configured by the facet is shown. See AfterShowEvent for details.

EntityProvider

The EntityProvider delegate method allows you to pass an entity instance to the opening screen:

@Autowired
private DataManager dataManager;

@Install(to = "editorScreen", subject = "entityProvider")
private User editorScreenEntityProvider() {
    User user = dataManager.create(User.class);
    user.setFirstName("John");
    user.setLastName("Doe");

    return user;
}

To register the entity provider programmatically, use the setEntityProvider() method.

Initializer

It is a handler that accepts the new entity instance and can initialize it before show in the editor screen. See Initializer for details.

To register the event handler programmatically, use the setInitializer() method.

OptionsProvider

ParentDataContextProvider

The ParentDataContextProvider delegate method allows you to pass parent DataContext to the opening screen:

@Autowired
private DataContext dataContext;

@Install(to = "editorScreen", subject = "parentDataContextProvider")
private DataContext editorScreenParentDataContextProvider() {
    return dataContext;
}

To set the parent DataContext supplier programmatically, use the setParentDataContextProvider() method.

ScreenConfigurer

Transformation

It is a handler that is invoked after the entity is selected and validated in the editor screen. See Transformation for details.

All XML Attributes

You can view and edit attributes applicable to the facet using the Component Inspector panel of the Studio’s Screen Designer.