Enabling EJB Injection into Vaadin 7 UI via Usage of Vaadin-CDI-Integration Addon

前端 未结 1 634
离开以前
离开以前 2021-01-25 10:42

I wasn\'t able to successfully integrate the official Vaadin-CDI-Integration-Addon, since after finishing the official integration instructions, the following Exception

1条回答
  •  甜味超标
    2021-01-25 10:48

    You have to work off the following steps to successfully integrate the official CDI-Integration-Addon into your Vaadin project.

    • Do exactly as stated in the official how-to.
    • Remove the ?restartApplication parameter from the URL. This avoids the Exception.
    • Inject the EJB as shown in the listing below.
    • Keep in mind to restart your application manually if necessary!

    @CDIUI
    public class ExampleCDIUI extends UI {
    
        @Inject
        MyLocalBeanInterface myBean;
    
        @Override
        public void init(VaadinRequest request) {
            Label label = new Label("Hello Vaadin user");
            setContent(label);
    
            // myBean should be accessible now.
    
        }
    
    }
    

    That's it. I hope this helps :-)

    0 讨论(0)
提交回复
热议问题