Future Objects in Converters

Hello, I am having an issue with Vaadin forms where I cannot find an appropriate solution. I have a form with a Binder where there is a Select component which show different types of distributions (gaussian, uniform, etc.). When I click on a distribution type, a dialog should open where you can enter the different parameters of the specific distribution. When clicking on a save button, the dialog should close and the actual instance of the distribution (not just the type) should be saved in the bean of the binder.

I tried to Implement a custom Converter which contains a Future Object. The converter should open the dialog and complete the future when the user clicks on a save button in the dialog.

Unfortunately, this approach does not work because the dialog is not opening when you call the show() function. Do you some recommendations how I could integrate this workflow with binders?

public class DistributionConverter implements Converter<Distributions.Types, DistributionConfig> {
    @Override
    public Result<DistributionConfig> convertToModel(Distributions.Types types, ValueContext valueContext) {
        CompletableFuture<DistributionConfig> future = new CompletableFuture<>();

        UI.getCurrent().access(() -> DistributionDialog.showDistributionDialog(null, types, future::complete));

        try {
            return Result.ok(future.get());
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Distributions.Types convertToPresentation(DistributionConfig distributionConfig, ValueContext valueContext) {
        if (distributionConfig == null)
            return null;

        return distributionConfig.getType();
    }
}```

The third of parameter of showDistributionDialog() is just a callback interface which is called when clicking on the save button

:wave: Can you (instead of dealing with futures) do something like:

        ComboBox<Map<String, Object>> comboBox = new ComboBox<>("Distribution", new HashMap<>() {{
            put("type", "gaussian");
        }}, new HashMap<>() {{
            put("type", "uniform");
        }});
        dialog.getFooter().add(new Button("Save", buttonClickEvent -> {
           dialog.close();                  
comboBox.getOptionalValue().ifPresent(map -> {
                map.put("someParameter", someParameter.getValue()); comboBox.setValue(map);
            });
        }));
        var button = new Button("Specify", buttonClickEvent -> dialog.open());
        add(comboBox, button);
        ```