@SpringView autowired

Why can’t I autowire @SpringView annotated classes?

Why do you think it is not possible?
The @SpringView anotation is anotated with @SpringComponent which is an alias for the spring annotation @Component.

So you are perfect able to autowire this vaadin views.

Further Readings:

https://vaadin.com/api/vaadin-spring/com/vaadin/spring/annotation/SpringView.html


https://vaadin.com/api/vaadin-spring/com/vaadin/spring/annotation/SpringComponent.html

I dug deeper and found that it has Failed to instantiate [com.vaadin.spring.internal.ViewCache]
when autowiring
full Exception is:
Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [cuscus.client.ui.presenter.LoginPresenter]
: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘viewCache’ defined in com.vaadin.spring.VaadinConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.vaadin.spring.internal.ViewCache]
: Factory method ‘viewCache’ threw exception; nested exception is java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null
at com.vaadin.spring.internal.DefaultViewCache.(DefaultViewCache.java:64)
at com.vaadin.spring.VaadinConfiguration.viewCache(VaadinConfiguration.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:345)
at com.vaadin.spring.internal.BeanStore.create(BeanStore.java:71)
at com.vaadin.spring.internal.UIScopeImpl$UIBeanStore.create(UIScopeImpl.java:282)
at com.vaadin.spring.internal.BeanStore.get(BeanStore.java:62)
at com.vaadin.spring.internal.SessionLockingBeanStore.get(SessionLockingBeanStore.java:46)
at com.vaadin.spring.internal.UIScopeImpl.get(UIScopeImpl.java:79)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:220)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1018)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:345)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at com.vaadin.spring.internal.ViewScopeImpl$BeanFactoryContextViewCacheRetrievalStrategy.getViewCache(ViewScopeImpl.java:132)
at com.vaadin.spring.navigator.SpringViewProvider.getViewFromApplicationContext(SpringViewProvider.java:440)
at com.vaadin.spring.navigator.SpringViewProvider.getView(SpringViewProvider.java:405)
at cuscus.client.ui.presenter.LoginPresenter.(LoginPresenter.java:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:345)
at com.vaadin.spring.internal.BeanStore.create(BeanStore.java:71)
at com.vaadin.spring.internal.UIScopeImpl$UIBeanStore.create(UIScopeImpl.java:282)
at com.vaadin.spring.internal.BeanStore.get(BeanStore.java:62)
at com.vaadin.spring.internal.SessionLockingBeanStore.get(SessionLockingBeanStore.java:46)
at com.vaadin.spring.internal.UIScopeImpl.get(UIScopeImpl.java:79)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:220)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1018)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:345)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at com.vaadin.spring.server.SpringUIProvider.createInstance(SpringUIProvider.java:203)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:191)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1464)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:381)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:351)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
at org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:133)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:174)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.vaadin.spring.http.HttpResponseFilter.doFilter(HttpResponseFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

line 64 of DefaultViewCache reads:
Navigator navigator = getCurrentUI().getNavigator();

so I suppose tha Navigator is not initialized because it is done in the initUI() as:

@SpringUI
public class AUiEntrance extends TranslatableUI implements Translatable {
private static final long serialVersionUID = 1L;

// private final ApplicationContext applicationContext;
private final I18N i18n;
private final SpringNavigator springNavigator;
private final LoginPresenter loginPresenter;

@Autowired
public AUiEntrance(LoginPresenter loginPresenter, I18N i18n, SpringNavigator springNavigator) {
this.loginPresenter = loginPresenter;
this.i18n = i18n;
this.springNavigator = springNavigator;

setLocale(Locale.US);
setContent(loginPresenter.getView());
}

/*

  • (non-Javadoc)
  • @see
  • org.vaadin.spring.i18n.support.Translatable#updateMessageStrings(java.util.Locale)
    */
    @Override
    public void updateMessageStrings(Locale locale) {
    getPage().setTitle(i18n.get(“app.title”));
    }

/*

  • (non-Javadoc)
  • @see package org.vaadin.spring.i18n.support.TranslatableUI#initUI(com.vaadin.server.
  • VaadinRequest)
    */
    @Override
    protected void initUI(VaadinRequest request) {
    getPage().setTitle(i18n.get(“app.title”));
    springNavigator.init(this, this);
    springNavigator.setErrorView(ErrorView.class);
    springNavigator.navigateTo(LoginView.VIEWNAME);

}

}

any way to fix this?

and I do not know why the source button in forum is not working sorry for that

actually found out that the getCurrentUI() returns null

Pom is:

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

<groupId>cuscus</groupId>
<artifactId>client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>client</name>
<description>Client to register container with the german customs.</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath />
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <vaadin.version>8.0.6</vaadin.version>
    <vaadin-spring.version>2.0.1</vaadin-spring.version>
    <vaadin-extension.version>2.0.0.RELEASE</vaadin-extension.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.2</version>
    </dependency>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>
    <!-- SPRING BOOT -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>hibernate-validator</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-instrument</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>hibernate-entitymanager</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
            <exclusion>
                <artifactId>hibernate-core</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- VAADIN -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-spring-boot</artifactId>
        <version>${vaadin-spring.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-push</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-bom</artifactId>
        <version>${vaadin.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <!-- VAADIN EXTENSIONS -->
    <dependency>
        <groupId>org.vaadin.spring.extensions</groupId>
        <artifactId>vaadin-spring-ext-core</artifactId>
        <version>${vaadin-extension.version}</version>
    </dependency>
    <dependency>
        <groupId>org.vaadin.spring.extensions</groupId>
        <artifactId>vaadin-spring-ext-boot</artifactId>
        <version>${vaadin-extension.version}</version>
    </dependency>
    <dependency>
        <groupId>org.vaadin.spring.extensions</groupId>
        <artifactId>vaadin-spring-ext-security</artifactId>
        <version>${vaadin-extension.version}</version>
    </dependency>
    <!-- VAADIN ADDONS -->
    <dependency>
        <groupId>org.vaadin.spring.addons</groupId>
        <artifactId>vaadin-spring-addon-eventbus</artifactId>
        <version>${vaadin-extension.version}</version>
    </dependency>
    <dependency>
        <groupId>org.vaadin.spring.addons</groupId>
        <artifactId>vaadin-spring-addon-i18n</artifactId>
        <version>${vaadin-extension.version}</version>
    </dependency>
    <dependency>
        <groupId>org.vaadin.spring.addons</groupId>
        <artifactId>vaadin-spring-addon-simple-mvp</artifactId>
        <version>${vaadin-extension.version}</version>
    </dependency>
    <!-- <dependency> <groupId>org.vaadin.spring.addons</groupId> <artifactId>vaadin-spring-addon-mvp</artifactId>
        <version>${vaadin-extension.version}</version> </dependency> -->
</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

I kinda fixed the UI by moving the Autowiring to a method an Explicit calling UI.setCurrent(this) and initializing the Navigator before but now I get another Exception there must be something wrong I must be able to Inject aka autowire Views into the UI am I not?
Now session.lock() code throws NullPointer because session is Null
@Override
public void destroy() {
session.lock();
try {
super.destroy();
} finally {
session.unlock();
}
}

Hm okay, seems like you are using parts of the vaadin4spring extensions and the official vaadin spring package together.

Which modules/addons of vaadin do you use in wich version?

So, after playing a bit arround it works well in this constelation of addon nad framework

Take a look at this simple project which shows the mechanics (hopefully ;))
https://github.com/ScreamingTree86/vaadini18n

The things that make me wonder in your Ui class is why do you call

setContent(loginPresenter.getView());

in your init method and later navigate to this view

springNavigator.navigateTo(LoginView.VIEWNAME); ?

As far as i understand, the Navigator finds and initializes the Views. But if you call the view before the navigator is initialized this may cause the problem.
On the other hand it may be simpler if you just initialize the i18n part inside the ui class and check if it is nessesary to show the login screen. If it is, navigate to the login view after you initialized the navigator. If not, navigate to another view.

The thing is when leaving out the LoginPresenter using the Navigator navigateTo() everything works fine… but I want to autowire the view for the simple mvp so the presenter is bound to the view and the Presenter is not instantiated because the View doesn’t know of the Presenter, and therefore I must autowire the presenter in the UI class and there the Exception occurs. Try and Autowire a @SpringView annotaed view in the UI class it shouldn’t work am I wrong?

is this a bug?

I"m not sure if all of this is meant to be used together. In my opinion you have to setup your navigator plain by yourself if you use simple mvp like if you use it without the spring boot integration. I experimentetd with the smiple mvp module in the past but never get around this construct. So i decided to do the mvp this way:

View:

[code]
@UIScope
@SpringView(name = “”)
public class TodoView extends VerticalLayout implements View {

@Autowired
public TodoView(TodoPresenter presenter) {
    this.presenter = presenter;
}

@PostConstruct
public void init() {
    presenter.setup(this);    
}

}
[/code]Presenter:

@UIScope 
@SpringComponent 
public class CirculationTodoPresenter implements Serializable{ 
    private TodoView view;
    void setup(View view) { 
        this.view = (CirculationTodoView) view; 
    }
}

Now you can use the SpringNavigator to lookup your views and have an mvp (the m can be autorwired in the presenter).

there must be another way, the view should not know about the presenter actually

jep… the way to achive this is to add an eventbus to the view and let the presenter receive events from the view, like button clicks. This way you can keep your presenter clean from vaadin stuff.
But there is a problem with this solution. If you have an spring bean (the presenter) with no autowire somewere the bean will not be created at runtime. So you have to load the preseneter bean at spring application startup time, or like you tried at ui load time. But okay at this point i stopped working at this problem because i think this got too far. Maybe someone knows a better way… would be very nice :smiley:

In my case i use this way of mvp (there are many many interpretations out there of what mvp should be… some people do strange things :wink: ) to have some Separation of Concerns and structure the code.

well why not do as is working i followed your suggestion and it is working now thnak you.

Finally i got it working like you would like to use it. With simple mvp and the eventbus…

Again take a look at my github project https://github.com/ScreamingTree86/vaadini18n

The essential part is to call

context.getBean(MainPresenter.class); in the main ui for every presenter after! the spring provider init. This will setup the presenter bean and the springprovider does the setup of the view bean. The sequence of initializations is essential in this case because the vaadin framework is not loaded on spring boot startup. So you need to wait until vaadin initializes the views and then initialize the presenters.