1 Reply Latest reply on Jun 27, 2018 6:08 AM by jam94

    get instance of IOCBeanDef

    jam94

      in errai 4.2.2 there is no method getInstance() in the IOCBeanDef interface,

      but it is used in the documentation.

       

      public MyManagedBean { 
        @Inject SyncBeanManager manager; 
        public void lookupBean() {
          IOCBeanDef<SimpleBean> bean = manager.lookupBean(SimpleBean.class); 
          if (bean != null) {
            // get the instance of the bean
            SimpleBean inst = bean.getInstance();
          }
        }
      }

       

      So how to get an instance of the bean.

      kindly regards.

        • 1. Re: get instance of IOCBeanDef
          jam94

          public MyManagedBean {

            @Inject SyncBeanManager manager;

            public void lookupBean() {

              SyncBeanDef<SimpleBean> bean = manager.lookupBean(SimpleBean.class);

              if (bean != null) {

                // get the instance of the bean

                SimpleBean inst = bean.getInstance();

              }

            }

          }