AbstractMainWindow with v7 Data Containers?

I am converting from v6 to v7. I have an AbstractMainWindow full of Datasources and charts.

I can change it all to Data Containers, but then the AbstractMainWindow dies with:

12:05:09.020 WARN  c.h.c.w.a.loginwindow.AppLoginWindow - Unable to login
java.lang.IllegalArgumentException: Unable to create screen mainWindow with type FRAGMENT
	at com.haulmont.cuba.web.sys.WebScreens.createScreen(WebScreens.java:177)
	at com.haulmont.cuba.web.sys.WebScreens.create(WebScreens.java:171)
	at com.haulmont.cuba.gui.Screens.create(Screens.java:70)
	at com.haulmont.cuba.web.App.createTopLevelWindow(App.java:296)
	at com.haulmont.cuba.web.DefaultApp.initializeUi(DefaultApp.java:173)
	at com.haulmont.cuba.web.DefaultApp.connectionStateChanged(DefaultApp.java:87)
	at com.haulmont.bali.events.EventHub.publish(EventHub.java:170)
	at com.haulmont.cuba.web.security.ConnectionImpl.fireStateChangeListeners(ConnectionImpl.java:228)
	at com.haulmont.cuba.web.security.ConnectionImpl.login(ConnectionImpl.java:106)
	at com.haulmont.cuba.web.app.loginwindow.AppLoginWindow.doLogin(AppLoginWindow.java:349)
	at com.haulmont.cuba.web.app.loginwindow.AppLoginWindow.doLogin(AppLoginWindow.java:318)
	at com.haulmont.cuba.web.app.loginwindow.AppLoginWindow.login(AppLoginWindow.java:264)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.haulmont.cuba.gui.xml.DeclarativeAction.actionPerform(DeclarativeAction.java:96)
	at com.haulmont.cuba.web.gui.components.WebFrameActionsHolder.handleAction(WebFrameActionsHolder.java:157)
	at com.vaadin.event.ActionManager.handleAction(ActionManager.java:248)
	at com.vaadin.event.ActionManager.handleActions(ActionManager.java:231)
	at com.haulmont.cuba.web.widgets.CubaOrderedActionsLayout.changeVariables(CubaOrderedActionsLayout.java:88)
	at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:611)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:457)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:400)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1577)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
	at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

Is there a v7 version of AbstractMainWindow?

As I go through the debugger on this, I find I get here:
image

As you can see, the AbstractMainWindow has a type of FRAGMENT, not SCREEN.

Even weirder, the Hierarchy says:
image

If I read this correctly, then my ExtAppMainWindow inherits from Screen, not ScreenFragment. Any idea why it is a Fragment?

In case it helps, here is the XML declaration:

<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd"
        caption="mainMsg://application.caption"
        xmlns:chart="http://schemas.haulmont.com/charts/charts.xsd"
        xmlns:main="http://schemas.haulmont.com/cuba/mainwindow.xsd">
public class ExtAppMainWindow extends AbstractMainWindow {

Note I am using cuba/screen/window.xsd and not cuba/window.xsd - so I can get the Data Containers instead of Datasources. I know if I switch back and use Datasources, it works fine. But the whole point is to switch to v7 Data Containers and Screens throughout my app.

After a lot of debugging, I found I had to do this to the XML window definiton:

<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd"
        caption="mainMsg://application.caption"
        xmlns:chart="http://schemas.haulmont.com/charts/charts.xsd"
        xmlns:main="http://schemas.haulmont.com/cuba/mainwindow.xsd"
        class="com.paslists.rade.web.screens.ExtAppMainWindow">

It now knows to open a Screen with the given Class and not a Fragment. HOWEVER, it shows up on Intellij like this (in RED), which made me think it was incorrect:
image

So maybe that can be fixed?

Hello @ericraskin

Unfortunately legacy screens do not support data containers.

I suggest you to implement your own custom Main screen based on new Screens API and register it with mainWindow id to replace the old one.

In next release new main screens will be available out of the box: GitHub.

Regards,
Daniil

OK, thanks.

Just FYI, my solution does work. Not sure why. I’m sure the next version’s method will be better.