Hello everybody!
I am trying to do an injection of some Entity (Table from MSSQL) with the help of @EJB.
I can inject this entity easily to UI-Class:
import com.mycompany.backend.testblock.DocuIF
import com.mycompany..models.entity.Document
import javax.ejb.EJB;
import com.vaadin.cdi.CDIUI;
@Theme("demo-theme")
@CDIUI("")
public class MyUI extends UI {
@EJB
DocuIF docu;
public static class Servlet extends VaadinCDIServlet {
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
//.....................
}
protected void init(final VaadinRequest request) {
List<Document> getallDocu = docu.getAll(); //---- Here the Entity can be perfectly initialised!!!
//..........
}
}
The problem: I am trying to initialise the same Entity in the class which is outside of UI-Class. I am triyn to inject this Entity in the VerticalLayout Class which implements the View:
[code]
import com.mycompany.backend.testblock.DocuIF
import com.mycompany…models.entity.Document
import javax.ejb.EJB;
import com.vaadin.cdi.CDIView;
public final class ConditionModel extends VerticalLayout implements View {
public static final String VIEW_ID = “dashboard”;
@EJB
DocuIF docu;
@CDIView(value = ConditionModel.VIEW_ID)
// I tried to play with some other annotations : @UIScoped; @ManagedBean; @SessionScoped but it does not help
public ConditionModel() { //constructor
List getallDocu = docu.getAll(); //Here docu = null
//…
}
}
[/code]Please help. How the Entity can be Injected, initialised in the class outside of UI?