Register and use Main Window Layou

Hi,
I use v7.2.14. Based on the section 4.5.8.2. Main Window Layout. " The platform includes the standard main window implementation in /com/haulmont/cuba/web/app/mainwindow/mainwindow.xml XML descriptor and corresponding AppMainWindow controller class. The standard implementation can be extended in the project, like any other application screen."

But I obtain the error when I use the code of Example of an extending screen:

<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        xmlns:ext="http://schemas.haulmont.com/cuba/window-ext.xsd"
        extends="com/haulmont/cuba/web/app/mainwindow/mainwindow.xml"
        class="com.haulmont.cuba.web.app.mainwindow.AppMainWindow">
  1. Where do I register the extended MainWindow?
  2. What is the code to register the custom MainWindow?
  3. Can I use difeferent MainWindow depending on the user to login?

Thanks

Hello!

AppMainWindow and its mainwindow.xml descriptor are considered legacy. It is better to use main window based on com.haulmont.cuba.web.app.main.MainScreen. If you have to use the legacy main window, you should register it in the web-screens.xml of the WEB module. For instance, the extended AppMainWindow:

Extended main window
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        class="com.company.demoapp.web.screens.main.legacy.ExtAppMainWindow"
        extends="/com/haulmont/cuba/web/app/mainwindow/mainwindow.xml"
        messagesPack="com.company.demoapp.web.screens.main.legacy">
    <layout>
        <split id="foldersSplit">
            <workArea id="workArea">
                <initialLayout></initialLayout>
            </workArea>
        </split>
    </layout>
</window>
public class ExtAppMainWindow extends AppMainWindow {
}

registration in the web-screens.xml:

<screen-config xmlns="http://schemas.haulmont.com/cuba/screens.xsd">
    <screen id="extMainWindow" template="com/company/demoapp/web/screens/main/legacy/ext-mainwindow.xml"/>
</screen-config>

Also, you should set the app property with screen id: cuba.web.mainScreenId=extMainWindow.

The id of the main screen is used by the framework and should be defined in the web-app.properties. So you can set only one main screen, but you can hiding components based on the user roles.

Note that Studio provides easy way to create or extend screens:

image

Hi,
thank you for your answer. The documentation does not say that this is legacy. Treats it as current from v7.2.
My project created with V7.2.14 is not legacy. I was looking for a way to make a custom main window.

Please,

  1. can you update the example from section 4.5.8.2 to customize a standard main window?
  2. Where I register ten main window and the class?

Thank you

Since v7.0 screens based on AbstractWindow, AbstractLookup, etc are considered legacy API (see 3.6.1.3. Screen Controller).

Unfortunately, I cannot find the 4.5.8.2 section in the 7.2 documentation. Do you mean this example?
About main and login screens you can read in 3.5.1.6. Root Screens section.

You can create the main screen using Studio.

  1. In the CUBA project tree do right click on the Screens folder and choose: New → Screen

image

  1. In the opened dialog select “Main screen with side menu” template

  1. Configure name and id of the screen.
  2. Then will be created controller and its descriptor. As controller uses @UiController annotation you don’t need to register it. Studio will add cuba.web.mainScreenId app property to the web-app.properties:
    cuba.web.mainScreenId=myExtMainScreen
    

See attached demo project: demo.zip (82.3 KB)

Thank you