How to open Dialog window from custom action?

Jmix 2.1.1

I am trying to open an entity detail view in edit mode, but in a DialogWindow. All of the examples show opening Dialogs from the controller and they use this as the origin view. How do I get the origin view from within a custom action?

Hello,

If your custom action implements the TargetAction interface, you can use this way:

View<?> view = UiComponentUtils.getView(((Component) target));

For example: io.jmix.securityflowui.action.AssignToUsersAction

        DialogWindow<View<?>> dialog = dialogWindows
                .lookup(UiComponentUtils.getView(((Component) target)), userClass)
                .withSelectHandler(this::selectHandler)
                .withAfterCloseListener(this::showNotification)
                .build();

Regards,
Nikita

1 Like