Hello,
i’m using Java Vaadin-Framework and want to use a Method in my MainView from my SecondView.
The Structure is:
- FooUI - declares an Navigator for the Views.
- Login - First Window, started by Navigator Class
- Settings - Setups some Settings, linked by Login Button over Navigator
- MainView - This is my MainView with the Application!
- SecondView - The Window where i pressing a Button and using Methods of MainView
My Problem is that if i accessing Methods of MainView, i have to Instantiate the MainView and then i generating a new MainView-Object what i dont want … because i want to use still the SAME INSTANCE of MainView. The reason is because the MainView was used by the User and i he should interact with it by the SecondView too …
I was reading about a Model-View-Presenter Architecture but i dont know how i can use it in my Project …
I tried to declare my MainView to a Singleton but i the problem is that if i call the .getInstance Method of MainView, i get a first-new Instance of the “Singleton” and not the Current Instance! …
Here is a Code-Snippet, if you need it:
public class ViewMain ... (
aMethod(){
... do something on ViewMain GUI...
}
}
public class SecondView ... {
ViewMain a = new ViewMain();
...
bMethod(){
a.aMethod(...)
}
}
Thanks for Help!
max