4 Replies Latest reply on Apr 19, 2007 6:37 AM by sammy8306

    ouject a non seam bean

    mousstik

      Hello :-)

      I've got two bean seam Seam1, Seam2.
      I ouject Seam1 in the context and I can get it in Seam2. It works well.

      In Seam1, I've got a getter/setter method on a non seam object Object1.
      When I try to get Object1 in my Seam2, I've got a nullPointerException.
      When I display attributes of my object1 in my JSF it works but I need to do some stuff before displaying.

      Could you please help me ?
      thank you

        • 1. Re: ouject a non seam bean
          pmuir

          Post your code

          • 2. Re: ouject a non seam bean
            mousstik

            ok

            @Name("seam1")
            @Scope(ScopeType.CONVERSATION)
            public class Seam1Action {
            
            private Model model;
            ....
            private String updateModel{ // method called on an actionCommand in JSF
             // ....
             setModel(model);
            }
            }
            

            @Name("seam2")
            @Scope(ScopeType.CONVERSATION)
            public class Seam2Action {
            @In
            private Seam1Action seam1;
            
             public Seam2Action() {
             sysout(seam1.getModel().toString());
            }
            
            ...
            }
            


            This code returns a null pointerException.
            When I comment the sysout and put
            <h:outputText value="#{seam2.seam1.model.attribute}" />
            

            it works ???

            • 3. Re: ouject a non seam bean
              mousstik

              Ok, sorry.
              I can't get my object Model in the constructor. My Model has not yet been created by seam...

              When I get in a getAttribute, it works very well.

              Thanks

              • 4. Re: ouject a non seam bean
                sammy8306

                You can't access injected beans in the constructor. Instead, use a method annotated with @Create to do this kind of initialization stuff.