EditorScreenFacet

EditorScreenFacet is essentially a ScreenFacet with an extended set of options for opening the editing screen.

Component’s XML-name: editorScreen.

Attributes

In addition to all the attributes that ScreenFacet has, EditorScreenFacet has its 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

Programmatic registration of the event handler: use the addAfterCloseEventListener() component method.

AfterShowEvent

Programmatic registration of the event handler: use the addAfterShowEventListener() component method.

OptionsProvider

Programmatic usage: call the setOptionsProvider() component method.

Initializer

Programmatic usage: call the setInitializer() component method.

Transformation

Programmatic usage: call the setTransformation() component method.

EntityProvider

To pass entity to the opening screen, EditorScreenFacet has EntityProvider.

@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;
}

Programmatic usage: call the setEntityProvider() component method.

ParentDataContextProvider

To pass data context to the opening screen, EditorScreenFacet has ParentDataContextProvider. To learn more about parent DataContext, see the DataContext page.

@Autowired
private DataContext dataContext;

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

Programmatic usage: call the setParentDataContextProvider() component method.

All XML Attributes

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