Page History
...
- Rely less on the Guice injection when it comes to the views.
Enhance the views with the 'factory' capabilities that abstract away the communication with the session store
Code Pro language java title FrameworkView public interface UiFrameworkView extends View { /** * Convenience method implementation. */ @Override... default Component asVaadinComponent() { if (this instanceof Component) { return (Component) this; } else { throw new RuntimeException(); } } /** * Wrapper around {@link ComponentProvider} capabilities. */ @SuppressWarnings("unchecked") default <T> T create(Class type, Object... args) { return getComponentProvider().newInstance((Class<T>) type, args); } default ViewProvider getViewProvider() { return new ViewProvider.Impl(getCurrentViewReference()); } default ComponentProvider getComponentProvider() { return new ViewComponentProvider(getCurrentViewReference()); } default UiContextReference getCurrentViewReference() { return ViewContextKeyRegistry.access() .lookUp(this) .orElseGet(() -> CurrentUiContextReference.get().getUiContextReference()); } default <T extends ViewContext> T bindContext(Class<? extends T> contextClass) { final T context = new ViewContextProxy().createViewContext(contextClass); SessionStore.access().getBeanStore(getCurrentViewReference()).put(contextClass, context); return context; } default void bindDatasource(Object definition) { SessionStore.access().getBeanStore(getCurrentViewReference()).put(DatasourceHolder.class, new DatasourceHolder(definition)); } }
...
Overview
Content Tools