How to call Method of one UI from Another UI without initializing and witho

How can we call FirstUI.Java method from SecondUI.java without initializing the FirstUI.java class and without making FirstUI’s method static?

  1. FirstUI.Java has multiple tabs buttons that needs to hide and show depending on what method (defined in FirstUI.java) SecondUI.java.
  2. SecondUI.java gets loads in the VerticalLayout present in FirstUI.Java. And is added to the Vertical layout by calling the constructor of the SecondUI.java.
  3. If I make FirstUI.Java’s method static which making buttons of tabs enable/disable we have to make the tab also static (This is what happening in my case). And whole application starts to create an issue.

Any Solution?

Can you create a small standalone code example that demonstrates the issue? It’s quite difficult to understand what you’re trying to achieve here. Which Vaadin version are you using?

You can try to pass a url parameter from the first ui and then read it in the second ui.
https://vaadin.com/docs/v14/flow/routing/tutorial-router-url-parameters.html

Olli Tietäväinen:
Can you create a small standalone code example that demonstrates the issue? It’s quite difficult to understand what you’re trying to achieve here. Which Vaadin version are you using?

I have attached the scenario as an image. And those hiding and showing should be happened by class B. We did it by making component static but messed up whole session.
18459366.png

Prashant Kumar:

Olli Tietäväinen:
Can you create a small standalone code example that demonstrates the issue? It’s quite difficult to understand what you’re trying to achieve here. Which Vaadin version are you using?

I have attached the scenario as an image. And those hiding and showing should be happened by class B. We did it by making component static but messed up whole session.

Yes, Vaadin components should never be stored in static variables.