Server pushes data to another view

Dar guru I am using the following code (located in the view) to push data from the server:

var o = this.getUI(); if (o.isPresent()) { var ui = o.get(); if (ui.isAttached()) { ui.access(command); } }

I have two views (switchable in the nav bar). This code works perfectly in one view and does not work in another. It looks like server always tries to push to the first view, even if it is not active. Could you please advice what’s wrong?

Hard to say from this snippet. Could you provide the relevant code of the two views?

I’ll try to provide the code but I guess it is somehow related to that issue: https://discord.com/channels/732335336448852018/1145982983170433054 I solved it setting tab position directly in afterNavigation but it looks like somewhere internally Vaadin still thinks that it is on the first view …

Sounds like you are using spring and the wrong scope for your Vaadin based components and therefore only one tab is updated or you are using static components somewhere down the line

Well, I am new in Vaadin, probably I did navigation wrong … Could you please look at the main layout attached? All views are annotated like
@Route(value = "transactions", layout = MainLayout.class)
Default view (that in fact accepts all server pushes) is also annotated as
@RouteAlias(value = "", layout = MainLayout.class)
MainLayout.java (2.46 KB)

Not really related, but you are misusing two concepts, routes and tabs. They can work together but they create a lot of burden for you. In the end you can just place multiple router links next to each other in a list and use some CSS to style them. Using the tabs just for styling is going to hurt you. (Like seen here)

@quirky-zebra , could you please point me to some example?

For what exactly? Just remove the tabs and add your links directly to the header

Talking about push, do I understand correctly that the same instance of UI is always used for all the views? How UI understands what view to push data to?

UI resembles a Browser Tab, each Browser Tab is a UI - so yeah, all views / routes share the same UI

It can only be one view / route active at the same time (skipping some deeper stuff about router layouts here)

I am really using spring … Should MainLayout be created in spring context? Currently it is just reverenced from the @Route.

No need to add any spring related annotation here

The mainlayout always stays the same for all views / routes

Thank you @quirky-zebra . Probably that push problem is not related to navigation … I am really stuck with that. When I push, for example, the notification being on the second view it is not shown. But it is shown immediatelly when I navigated to the first view …

What do you mean with “first view”? Your first view / route or do you have multiple browser tabs?

If you mean “first view” / try removing the tabs and see if it works :wink:

No, the single browser tab but several route links. Ok, will try to remove tabs, thank you for your time!

Well, it was my fault. I have manual push configured and just forgot to invoke ui.push … Nevertheless it’s rather confusing that push behaves such a way.