Parameter from browser and editor screen

How can I get the parameter I send from browser screen to editor screen?
Here is how I am sending parameter from browser screen

openEditor(material, WindowManager.OpenType.NEW_TAB, ParamsMap.of("editorScreenType", "sourcelist")).addCloseWithCommitListener(() -> materialsDs.refresh());

Thanks for helping how can I capture the parameter and it’s value to use in the editor screen.

second question, is there any way we can send parameter from create / edit button actions to editor screen?

Hello, @mortozakhan

It can be managed via injecting this parameter into editor controller with @WindowParam annotation.

You can find additional information here: Controller Dependency Injection

Regards,
Daniil.

In the legacy platform version we can pass the a parameter from browser screen to Editor screen through table or dataGrid’s create/edit handlers like as follows:

in Browser screen:

 @WindowParam
    String transactionType;

    @Override
    public void init(Map<String, Object> params) {
        retailInvoicesTableCreate.setWindowParams(ParamsMap.of("transactionType", transactionType));
    }

in Editor Screen:

    @WindowParam(name ="transactionType")
    String transactionType;

    @Override
    public void ready() {
        activityTypesDs.refresh(ParamsMap.of("tranType", transactionType));
    } 

How can we do the same in Platform V7.x? Checked the V7.1 Documentation but didn’t find specific info, I may have missed it but thanks for your help.

Hi,

Currently you can override action and create editor yourself e.g.:

    @Subscribe("planetsTable.edit")
    public void onPlanetsTableEdit(Action.ActionPerformedEvent event) {
        screenBuilders.editor(planetsTable)
            .editEntity(planetsTable.getSingleSelected())
            .withOptions(new MapScreenOptions(ParamsMap.of("some", 10)))
            .show();
    }

or even better define api for parameter in the edit screen:

        PlanetEdit screen = screenBuilders.editor(planetsTable)
            .withScreenClass(PlanetEdit.class)
            .editEntity(planetsTable.getSingleSelected())
            .withOptions(new MapScreenOptions(ParamsMap.of("some", 10)))
            .build();
        
        screen.setParam("value");
        screen.show();

Release 7.2 will contain mechanism for convenient customization of standard actions (issue), e.g.:

@Install(to = "petsTable.edit", subject = "screenOptionsSupplier")
protected ScreenOptions petsTableEditScreenOptionsSupplier() {
    return new MapScreenOptions(ParamsMap.of("someParameter", 10));
}

or

@Install(to = "petsTable.edit", subject = "screenConfigurer")
protected void petsTableEditScreenConfigurer(Screen editorScreen) {
    ((PetEdit) editorScreen).setSomeParameter(someValue);
}

It was even shorter, straight-forward and simple in V6.x

salesQuotationsTableCreate.setWindowParams(ParamsMap.of("transactionType", transactionType));

In 7.2 you can also do it without install delegate:

createAction.setScreenOptionsSupplier(() -> new MapScreenOptions());

for Create button, the code as per V7.1 requires like this:

@Subscribe("salesQuotationsTable.create")
public void onSalesQuotationsTableCreate(Action.ActionPerformedEvent event) {
    SalesQuotation salesQuotation = metadata.create(SalesQuotation.class);
    screenBuilders.editor(salesQuotationsTable)
            .editEntity(salesQuotation)
            .withOptions(new MapScreenOptions(ParamsMap.of("docname", docname)))
            .show();
}