Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Get application context in @SpringUI class

Daniel Daniel
5 years ago May 22, 2016 12:33pm
Marco Collovati
5 years ago May 22, 2016 12:40pm

Inject Application context markin your field with @Autowired annotation (or use constructor injection)  or make yout UI class implement ApplicationContextAware interface

@SpringUI
public class MyVaadinUI extends UI {
    @Autowired
    ApplicationContext applicationContext;
}

or 

@SpringUI
public class MyVaadinUI extends UI implements ApplicationContextAware {
    ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext appCtx) {
        this.applicationContext = appCtx;
   }
}

 

Daniel Daniel
5 years ago May 22, 2016 12:43pm
Marco Collovati
5 years ago May 22, 2016 12:56pm

ApplicationContext @Autowired works well for me, also importing  bean definitions from xml file with @ImportResource.

Could you post some more code?

Daniel Daniel
5 years ago May 22, 2016 1:11pm