Renaming screens cannot find the edit part

I build two screens by selecting the entity, create generic UI screen, Entity browser and editor screens.
Their names are scr_name-browse and scr_name-edit and I rename them to something else.
Then the browse screen keeps on working as expected when called from the menu with the new name.
But when I am trying to create or edit a record it’s searching for the old name of the edit screen and I am trying to figure out where is this name defined and how can I change it.
Thank you in advance.
BR/NA

Hi,

By default, {entity_name}.edit screen Id is used for the CreateAction and EditAction, for example sales$Customer.edit. So, I would suggest checking your edit screen Id to make sure that it matches this requirement.

See the docs for more details.

You are right.
Thank you.
BR/NA

Sorry for coming back to this, but obviously there is something that I don’t understand.
I will try to explain what I am trying to achieve.
I have an entity called param having two attributes paramName and paramType.
I want to create two screens one for Geography where paramType = 10 and one for Cost Centers where paramType = 20.
Still as I said the browse screens are working perfectly but I am having issues with the edit.
I believe that the reason as you correctly are pointing is the ID where the value is <project_name>$Param.edit.
If I change this none of the edit screens is working.
But as I understand it, I need to change it since the edit screen has different labels according to the parameter I am supposed to enter and paramType is something that the screen is supposed to pass to the database and not the user.
Thank you in advance.
BR/NA

If you need to have different layouts for the Param entity according to the paramType attribute, I would suggest checking the param type in the postInit method of the Edit screen and update the layout according to type. For example:

@Override
protected void postInit() {
    // We have to check if entity is no new, i.e. it has grade
    // Alternatively we can check if grade is null 
    if (!PersistenceHelper.isNew(getItem())) {
        CustomerGrade grade = getItem().getGrade();
        switch (grade) {
            case PREMIUM:
                // Update UI according to the PREMIUM grade
                ...
                break;
            case STANDARD:
                // Update UI according to the STANDARD grade
                ...
                break;
        }
    }
}

Unfortunately this unclear for me. Could you explain in more detail so that I could provide you useful advice?

Alternatively, you can specify editor screen Id for CreateAction and EditAction according to the param type in the BeforeActionPerformedHandle, for example:

@Named("customerTable.edit")
private EditAction customerTableEdit;
@Inject
private Table<Customer> customerTable;

@Override
public void init(Map<String, Object> params) {
    customerTableEdit.setBeforeActionPerformedHandler(() -> {
        Customer selected = customerTable.getSingleSelected();
        if (selected != null) {
            CustomerGrade grade = selected.getGrade();
            switch (grade) {
                case PREMIUM:
                    customerTableEdit.setWindowId("customer-edit-premium");
                    break;
                case STANDARD:
                    customerTableEdit.setWindowId("customer-edit-standard");
                    break;
            }
        }
        return true;
    });
}

But I suggest not to have several edit screens, unless this is really necessary

Just think that within the same entity (table) we are having the information for two parameters.
Geography where the paramType = 10 and Cost Centers where the paramType = 20.
In order to achieve this I am having two different screens
The paramGEO-browse.xml where I modified the datasource to “select e from sci$Param e where e.paramType = 10” and the paramCC-browse.xml where I modified the datasource to “select e from sci$Param e where e.paramType = 20”.
These two are called from the menu and they return the expected data.
Now the thing is that when I am clicking on the create or edit button the paramGEO-edit.xml and paramCC-edit.xml screens are supposed to open respectively and there is my problem and where I am getting the error.
If you could assist me on this I would really appreciate it.
BR/NA

First of all, I would strongly recommend that you use a single screen to show Parameter entities and use screen params to obtain a type to filter values. For example:

web-menu.xml

...
<item id="standardCustomers"
      screen="sales$Customer.browse">
    <param name="grade"
           value="10"/>
</item>
<item id="highCustomers"
      screen="sales$Customer.browse">
    <param name="grade"
           value="20"/>
</item>
...

As you can see I use the same screen, but with different menu item Id and different params.

customer-brose.xml

...
<collectionDatasource id="customersDs"
                      class="com.company.sales.entity.Customer"
                      view="_local">
    <query>
        <![CDATA[select e from sales$Customer e]]>
        <filter>
            <and>
                <c>e.grade = CAST(:param$grade NUMERIC(2))</c>
            </and>
        </filter>
    </query>
</collectionDatasource>
...

By using query filter you can have all in one screen:

  • if the grade screen param is passed then the result entity list will be filtered
  • if no screen param is passed then the full entity list will be displayed

I still see no need for different edit screens. I suggest the following:

  • Use the grade screen parameter (if it exists) as an initial value for the CreateAction
public class CustomerBrowse extends AbstractLookup {

    @Named("customersTable.create")
    private CreateAction customersTableCreate;

    @WindowParam(name = "grade")
    private String gradeStr;

    @Override
    public void init(Map<String, Object> params) {

        if (grade != null) {
            CustomerGrade grade = CustomerGrade.fromId(Integer.valueOf(gradeStr));
            customersTableCreate.setInitialValues(ParamsMap.of("grade", grade));
        }
    }
}
  • If there is initial grade value, hide the type field in the edit screen, so that a user can’t change its value
public class CustomerEdit extends AbstractEditor<Customer> {

    @Named("fieldGroup.grade")
    private LookupField gradeField;

    @Override
    protected void postInit() {
        gradeField.setVisible(getItem().getGrade() == null);
    }
}

In this case, your Edit screen will also be universal and widely applicable.