2 Replies Latest reply on Jul 28, 2011 6:55 PM by Tim Evers


    Lee Clout Newbie

      What's diffenet Component.getInstance from new object?
      They always get a object, right?

        • 1. Re: Component.getInstance
          omid pourhadi Apprentice

          Component.getInstance : gets Seam component that means only object with @Name annotation
          new object can be every java object

          • 2. Re: Component.getInstance
            Tim Evers Master

            More importantly is that you should never use new on a Seam component/bean. If you instantiate a Seam bean by doing

            MySeamBean x = new MySeamBean();

            then that instance (x) of MySeamBean is not going to be a part of the Seam context and will not be managed by Seam. This means that your @In/@Out or any other Seam related interceptors will NOT work on that instance.

            So, at the end of the day when dealing with a Seam component/bean you should use either @In or Component.getInstance, or any other Seam supported operation that creates Seam beans but, never use the new operator.