appWindow customization

I am trying to use my customized appWindow as per the section 4.5.8.2. Main Window Layout in the manual and have some questions.

  1. Where do I register the extended MainWindow, is it here: modules > gui > source > screens.xml?
  2. What is the correct code to register the custom mainWindow?
  3. How can i call a screen immediately after log-in and displaying this custom mainWindow automatically?

I have attached a demo project in case you would like to take a look.

demo-appwindow.zip (320.8K)

1 Like

Hi,
There is a mistake in the platform documentation: custom main window should be registered in the ‘modules\web\src\web-screens.xml’. Because it works only in the web module.

To simplify the main window creation Studio presents special functionality:

  1. Open the ‘Screens’ tab in the main menu (left-hand panel)
  2. Find the ‘Create main window’ link.
    When the link is pressed, an extension of the main window is created automatically.

Thank you for a good question, we will fix documentation soon.

Here is a simple project which illustrates a custom main window creation.

MainWindow.zip (28.3K)

Hi Rostislav
Thank you so much. And about my 3rd question, do you suggest I use init method where I call the screen that I want to show immediately after log-in and showing the mainWindow?

Hi Rostislav
As I want t o create work area, header, footer etc. in the main window, I have created the main window as advised. However, after I have created the main window following the XML code in the user guide, i am having an exception as follows:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        class="com.company.sample.gui.MainWindow"
        xmlns:ext="http://schemas.haulmont.com/cuba/window-ext.xsd"
        xmlns:main="http://schemas.haulmont.com/cuba/mainwindow.xsd">
    <layout expand="middlePanel">
        <hbox ext:index="0"
              margin="true"
              stylename="gray"
              width="100%">
            <label align="MIDDLE_CENTER"
                   value="Header"/>
        </hbox>
        <main:menu ext:index="1"
                   width="100%"/>
        <split id="middlePanel"
               ext:index="2"
               orientation="horizontal"
               pos="80"
               width="100%">
            <main:workArea id="workArea"
                           height="100%"
                           width="100%">
                <main:initialLayout stylename="red">
                    <label align="MIDDLE_CENTER"
                           value="Work Area (Initial Layout)"/>
                </main:initialLayout>
            </main:workArea>
            <main:foldersPane height="100%"
                              stylename="blue"
                              width="100%"/>
        </split>
        <hbox ext:index="3"
              margin="true"
              stylename="gray"
              width="100%">
            <label align="MIDDLE_CENTER"
                   value="Footer"/>
        </hbox>
    </layout>
</window>

It’s automatically registered in the screen file


    <screen id="mainWindow"
            template="com/company/demoappwindow/web/mainwindow/ext-mainwindow.xml"/>

I have attached the demo app, thanks for your further help.

demo-appwindow.zip (321.8K)

Hi,
If you want to create clear Main window (using XML from the documentation), you should inherit it from the AbstractMainWindow - class. Modify your MainWindow.java as follows:

package com.company.sample.gui;

import com.haulmont.cuba.gui.components.AbstractMainWindow;
public class MainWindow extends AbstractMainWindow {
}

After that the code from documentation should work well.

ExtMainWindow generated by Studio extends AppMainWindow. The ‘id’ attribute of redefined components should be specified in that case. So the NPE during login occurs because the id = “mainMenu” was not set for the main:menu component in your XML descriptor.

Considering your 3rd question:
Required screen could be opened right after login from the ‘ready()’ method of the Main window.
The information of how to open the screen could be found here: https://doc.cuba-platform.com/manual-6.1/abstractFrame.html

public class ExtAppMainWindow extends AppMainWindow {
    @Override
    public void ready() {
        super.ready();
        openWindow("demo$Customer.browse", WindowManager.OpenType.THIS_TAB);}

Hi
I want the new main window to be exactly the same in the user guide sample I.e. Having work area, footer area etc. Wondering if there is anything wrong as its not working.