I'm new to Java EE and I have a task to do but no idea how to do it. I need to create a manged bean that will be scoped on the application. Everytime we start the application, the bean needs to load a list of data from database. So, according to my research on the web, I need:
So how to set loading at the application start-up ? And then how to get these loaded datas from anywhere in the app?
This is quite easy since JSF 2.x, just add attribute eager
to the @ManagedBean
annotation.
@ApplicationScoped
@ManagedBean(eager=true)
public class InitializerBean {
@PostConstruct
public void init() {
//init your DB here
}
}