Cuba 7.2 to Jmix 2.4

Hi,

In our company, we have built several, sometimes very extensive, business applications in the Cuba framework. These are all desktop applications where the user typically sits at a PC with a large screen. The applications are classic in structure: there is a menu bar, and for each module, a tab opens in the main window with the list of data, and editing takes place in a popup menu.

Now, Cuba is being discontinued in this form, so we are in a situation where we have to port to Jmix.

Unfortunately, the conversion path has proven to be unfeasible (the conversion, in my view, is not doable because far too much needs to be corrected).

Therefore, I have created a new project in Jmix 2.4 with an existing data model and even got it running.

What I have not managed is:

To create a "tab-based" application, i.e., that for each application opened by the user, a tab opens in the main screen (and also remains open).

A popup-based application, i.e., when I want to edit an entity in the list, a popup window should open in the foreground, and the list behind it must remain visible. This type of editing is mandatory because the customers want it.

Question: Where is my mistake?
In Cuba, something like this was possible out of the box.

Regards, Martin

Hi Martin,

To create a “tab-based” application, i.e., that for each application opened by the user, a tab opens in the main screen (and also remains open).

This feature is planned for the next Jmix release in Feb 2025, see Support for Tabbed Window mode · Issue #2154 · jmix-framework/jmix

A popup-based application, i.e., when I want to edit an entity in the list, a popup window should open in the foreground, and the list behind it must remain visible. This type of editing is mandatory because the customers want it.

This is supported in Jmix from the start, see Opening Dialog Windows.

When using standard create/edit actions, just set their openMode property to DIALOG to open the detail views in a popup window:
image

Regards,
Konstantin

Hi,

I have one more question: When a detail window is opened as a dialog, how can I control the size of the window or the title of the popup window?

In CUBA, you could get the Window object in the afterShowEvent and manipulate it (for example, the size). What is the similar way in Jmix?

Thanks, Martin

You can add the @DialogMode annotation to the detail view class:

// ...
@DialogMode(width = "100%", height = "100%")
public class UserDetailView extends StandardDetailView<User> {

Either obtain a window when opening programmatically and set its dimensions:

DialogWindow<UserDetailView> dialogWindow = dialogWindows.detail(usersDataGrid)
        .withViewClass(UserDetailView.class)
        .build();
dialogWindow.setSizeFull();
dialogWindow.open();

In order to set the view title, override the getPageTitle() method (see View Methods):

private String title;

public void setTitle(String title) {
    this.title = title;
}

@Override
public String getPageTitle() {
    return title;
}

You can invoke setTitle() when opening the view:

DialogWindow<MyView> dialogWindow = dialogWindows.detail(myDataGrid)
        .withViewClass(MyView.class)
        .build();
dialogWindow.getView().setTitle("some title");
dialogWindow.open();

Hello Konstantin,

I meant something different: I have annotated the DetailView class with @DialogMode(width = “700px”, height = “500px”, modal = true, resizable = true) and extended the List class with

so that the dialog is always used as the mask type (without special calls). Now the question arises, how can I influence the popup display within the View Controller: Example: In the User class, the password field is displayed when creating, but not when editing. Here I would like to reduce the size of the popup.

In Cuba, we do it as in the following example:

@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
if (getWindow() instanceof DialogWindow) {
DialogWindow windowDialog = (DialogWindow) getWindow();
Element element = getSettings().get(saveName+“DialogSizes”);

    String width = element.attributeValue("width");
    if (!Strings.isNullOrEmpty(width)) {
        windowDialog.setDialogWidth(width);
    }
    String height = element.attributeValue("height");
    if (!Strings.isNullOrEmpty(height)) {
        windowDialog.setDialogHeight(height);
    }
}

}

In Jmix, however, I have not found a way to access the DialogWindow within the controller?

Best regards, Martin

You can do it as follows:

Dialog dialog = UiComponentUtils.findDialog(this);
if (dialog != null) {
    dialog.setWidth("80em");
    dialog.setHeight("60em");
}