2 Replies Latest reply on Apr 23, 2007 11:34 AM by cptnkirk

    Obtaining a handle to a EntityHome object

    hvram

      Hi
      The seam-gen code has reference to the EntityHome object .

      In the .java file if I do a
      Object o = new EntityHomeObject<>

      the compilation goes thru but somethings start failing . ( logging fails etc )

      I searched the forums and found that this is the NOT the way to do .

      But I am not able to find any other way to obtain a new handle to the EntityHome .

      So my question is how to get a handle to the EntityHome object from the java code ?

      Regards
      Hari

        • 1. Re: Obtaining a handle to a EntityHome object
          damianharvey

          I was just looking at this myself this morning.

          Instead of calling:

          SomeObjectHome myHome = new SomeObjectHome();

          You should instead use:
          SomeObjectHome myHome = Component.getInstance("someObjectHome");


          Where "someObjectHome" is the @Name given to the Home Object. If you don't do it this way then 'Seam can't do it's magic' and you'll get NullPointerExceptions on injected objects like @Logger.

          Cheers,

          Damian.

          • 2. Re: Obtaining a handle to a EntityHome object

            EntityHome was designed to be able to be used by JSF CRUD pages without needing additional java code. That said, it's generally preferred to access Seam components via @In than Component.getInstance().