4 Replies Latest reply on Oct 28, 2008 4:11 AM by taffb

    using an session ejb as a manged bean

    taffb

      Hi all,
      Can I use a session ejb as a managed bean?

      Why?
      I need to update a page when an ejb method is invoked by anbother ejb.

      Or is there another(better) way to notify a managed bean by the ejb?

      thanks in advance,
      Taff

        • 1. Re: using an session ejb as a manged bean
          fabmars

          I think you can't without using other frameworks on top. Check Seam and SpringFaces for example, although I'm not perfectly aware of what's possible with them.

          Personally, I declare simple POJO's managed beans which have @EJB injections.

          The managed bean may have a method that calls one of the EJB methods. Simple.

          • 2. Re: using an session ejb as a manged bean
            taffb

            Thanks for your quick reply,
            It was the answer I expected, but the one I did not hope for.

            Basically I need the call the other way around.
            Not that the managed bean call a method in the ejb (that is simple I agree), rather the ejb call a method in the managed bean.

            Thanks,
            taff

            • 3. Re: using an session ejb as a manged bean
              shadowcreeper

              Does this not work?

               final FacesContext faces = FacesContext.getCurrentInstance();
               final SessionBeanWidget sessionBean
               = (SessionBeanWidget)faces.getApplication().getVariableResolver().resolveVariable( faces, "SessionBeanWidget" );
              


              ...assuming you have already created it via your web page with a #{SessionBeanWidget} reference...

              • 4. Re: using an session ejb as a manged bean
                taffb

                Thanks,
                unfortunatley not. The session bean is not in the FacesContext
                and when I try to call the facesContext object from the ejb I always get null

                I really am at a loss
                any (further) help would be greatly appreciated.
                thnkas,
                taff