Access a mainWindow component from another screen

Hi,

Is there a possible way to access a component, let say a label, located in the mainWindow from any other screen (AbstractFrame) ?
What I’m trying to do is to update a status message located on the mainWindow, after updating entities from its screen editor.

Hi,

it is possible. Just recently i had a very similar question. I solved it through the instance of AppUI. You can do AppUI.current.getTopLevelWindow()

An example of this can be found here (Although i’m not really sure if this a best practice…).

Here you can have a look at some details on the web specific classes: Web Client Specifics - CUBA Platform. Developer’s Manual

An alternative would be to create a Timer that will every 5 seconds update the status of the mainWindow. In 6.4 the SideMenu does that for the badge texts: SideMenu - CUBA Platform. Developer’s Manual.

Bye
Mario

Hi Mario,

Thanks a lot, this is what I was looking for.

in java it looks like : ExtAppMainWindow mainWindow = (ExtAppMainWindow)AppUI.getCurrent().getTopLevelWindow(); (if mainwindow is extended)

The casting of the getTopLevelWindow() is causing an issue when you modify the casted object.
For instance, if you modify ExtAppMainWindow during dev mode (browser refresh) it’s going to throw an exception saying that can’t be cast… but once you restart the project it will be OK …