Closed peter-mueller closed 8 years ago
In der MainUI wird der Navigator erstellt und gesetzt. Dieser sollte dann fix bleiben, da die UI für jede Vaadin Instanz auch fix bleibt. MainUI.class:
this.navigator = new Navigator(this, componentContainer);
this.navigator.addProvider(viewProvider);
setNavigator(this.navigator);
Beim Eventbus schaut das etwas schlechter aus, da man diesen in die UI und die damit verbundene VaadinSession packen müsste. Und zwar so, dass man es auch à la Navigator von überall bekommt. Ich sehe da derzeit keine Möglichkeit, dies auf eine schöne/praktikable Weise umzusetzen.
Dies wäre z.B. eine sehr hässliche Möglichkeit, die aus den Libs nicht möglich ist:
EventBus bus = ( (MainUI) UI.getCurrent() ).getEventBus();
So OK? Mit Navigation das funktioniert so.
/**
* Provides a simple EventBus.
*
* @author rene.zarwel
*/
public class EventBus extends reactor.bus.EventBus implements Serializable {
private static EventBus eventBus = null;
public static EventBus make() {
if (eventBus == null)
return eventBus = new EventBus();
return eventBus;
}
private EventBus() {
super(SynchronousDispatcher.INSTANCE);
}
}
Dann haben wir einen eventbus für alle Sessions aller User und das wäre vielleicht keine gute Idee.
Von meinem iPhone gesendet
Am 16.10.2015 um 07:46 schrieb Peter Müller notifications@github.com:
So OK? Mit Navigation das funktioniert so.
/**
- Provides a simple EventBus. *
@author rene.zarwel */ public class EventBus extends reactor.bus.EventBus implements Serializable {
private static EventBus eventBus = null;
public static EventBus make() { if (eventBus == null) return eventBus = new EventBus(); return eventBus; }
private EventBus() { super(SynchronousDispatcher.INSTANCE); } } — Reply to this email directly or view it on GitHub.
Nein, ist getestet und funktioniert scheinbar. Geht so nicht
So ?:
If you also want to access the variables of your own subclass of UI in a static way you can use the following pattern to create a getCurrent() method that is narrowed to your UI class:
public class MyApplicationUI extends UI {
// ...
public static MyApplicationUI getCurrent() {
return (MyApplicationUI) UI.getCurrent();
}
}
You can then statically access your own UI subclass as follows:
MyApplicationUI.getCurrent().getMyUIScopedVariable();
By that, managing ThreadLocal variables isn’t necessary any longer. Statically accessing session-scoped variables through the VaadinSession can be achieved in a similar way.
Das ist besser :smile:
Von meinem iPhone gesendet
Am 16.10.2015 um 08:15 schrieb Peter Müller notifications@github.com:
So ?:
If you also want to access the variables of your own subclass of UI in a static way you can use the following pattern to create a getCurrent() method that is narrowed to your UI class:
public class MyApplicationUI extends UI {
// ...
public static MyApplicationUI getCurrent() { return (MyApplicationUI) UI.getCurrent(); }
} You can then statically access your own UI subclass as follows:
MyApplicationUI.getCurrent().getMyUIScopedVariable(); By that, managing ThreadLocal variables isn’t necessary any longer. Statically accessing session-scoped variables through the VaadinSession can be achieved in a similar way.
— Reply to this email directly or view it on GitHub.
Ist übrigens meine Lösung von oben
Von meinem iPhone gesendet
Am 16.10.2015 um 08:15 schrieb Peter Müller notifications@github.com:
So ?:
If you also want to access the variables of your own subclass of UI in a static way you can use the following pattern to create a getCurrent() method that is narrowed to your UI class:
public class MyApplicationUI extends UI {
// ...
public static MyApplicationUI getCurrent() { return (MyApplicationUI) UI.getCurrent(); }
} You can then statically access your own UI subclass as follows:
MyApplicationUI.getCurrent().getMyUIScopedVariable(); By that, managing ThreadLocal variables isn’t necessary any longer. Statically accessing session-scoped variables through the VaadinSession can be achieved in a similar way.
— Reply to this email directly or view it on GitHub.
Testen ob das von überall aus geht:
Und dann eine ähnliche Lösung für den EventBus bauen.
@xdoo Bitte bestätigen dass es pro GUI nur einen Navigator und einen EventBus gibt.