[FlowUI] Sending parameter to next screen

I have added an action to ComboBox to create a new Material as you see in the image below (red).

image

I am using the following code to call the dialog “Material aprl”.

  dialogWindows.detail(this, MaterialAprl.class)
                .withViewClass(MaterialAprlDetailView.class)
                .newEntity()
                .withAfterCloseListener(afterCloseEvent -> {
                    if (afterCloseEvent.closedWith(StandardOutcome.SAVE)) {
                        MaterialAprl materialAprl = afterCloseEvent.getView().getEditedEntity();
                        getEditedEntity().setMaterial(materialAprl);
                    }
                })
                .open();

How can I send the customerProfile parameter while using the dialogWindows?

In Jmix documentation I found the following guide:

Use withRouteParameters() and withQueryParameters() methods of the fluent interface to pass parameters to the view opened by navigation.

However, I didn’t find any such option in dialogWindows. Can you guide/direct me to the link that explains how to use those parameters as I didn’t find it?

Hi,

Instead of open(), call build() to obtain a dialog instance and get wrapped view, e.g.:

DialogWindow<UserDetailView> dialog = dialogWindows.detail(this, User.class)
        .withViewClass(UserDetailView.class)
        .build();

UserDetailView view = dialog.getView();
view.setFoo();

dialog.open();

Regards,
Gleb

2 Likes

Thank you Gleb.
Now my complete code looks as follows that works perfectly:

 @Subscribe("materialField.createMaterial")
    public void onCreateMaterial(ActionPerformedEvent event) {

        DialogWindow<MaterialAprlDetailView> dialog = dialogWindows.detail(this, MaterialAprl.class)
                .withViewClass(MaterialAprlDetailView.class)
                .newEntity()
                .withAfterCloseListener(afterCloseEvent -> {
                    if (afterCloseEvent.closedWith(StandardOutcome.SAVE)) {
                        MaterialAprl materialAprl = afterCloseEvent.getView().getEditedEntity();
                        getEditedEntity().setMaterial(materialAprl);
                    }
                })
                .build();
        MaterialAprlDetailView view = dialog.getView();
        view.getEditedEntity().setCustomerProfile(getEditedEntity().getCustomerProfile());

        dialog.open();

    }