How to set screen id?

Hello,
I am new to cuba.platform and currently try my first steps. From the developer manual, I see that an edit screen’s id should be {entity_name}.edit (see § 4.5.1.1.4) for standard actions to work correctly. I want to have 2 edit screens for the same entity in my application. Which id should I give to the second edit screen so that standard actions in this screen still work correctly?

Thank you for an answer, kind regards,
Markus

1 Like

Hi Markus,
These names are used in actions by convention, but you can set any screen ID for an action explicitly. Inject the action to the screen controller and use setWindowId() method.
See https://doc.cuba-platform.com/manual-6.1/list_actions.html and this topic: https://www.cuba-platform.com/discuss/t/how-to-create-a-specific-window-from-create-table-action#comment-885

Thank you very much, I’ll try this…

Hello again,

I tried to implement the solution that Konstantin proposed. I do not succeed to get this done. To inject a standard action in the controller class, some source code like the following is necessary (taken from the forum topic in Konstantin’s comment):


    @Named("someEntitiesTable.create")
    private CreateAction someEntitiesTableCreate;

    @Override
    public void init(Map<String, Object> params) {
        someEntitiesTableCreate.setWindowId("project$customeditorscreen");
        super.init(params);
    }

I want to inject the window commit action. I do not find the name string I have to specify for the Named-attribute and the class name of the window commit action. Can anybody help me with this?

Thank you in advance!
Markus

Hi Marcus,

By standard actions we assume actions that invoke other screens (such as Create, Edit, Lookup, etc.). The editor’s commit action is not in this category and we do not recommend injecting this action. If you want to intercept the screen commit, override postValidate(), preCommit() or postCommit() methods in your screen controller. See JavaDocs on AbstractEditor and the documentation.

Hi Konstantin,

thank you for your reply. I just only want the commit action to work properly. I thought that this is not the case when I create a second edit screen having an id xyz instead of {entity_name}.edit. So this will work with the commit action without injecting it and setting the window id?

Kind regards,
Markus

Sure, the screen behavior does not depend on what ID you have assigned to the screen. The ID is only for invoking the screen from other screens or menu.