6 Replies Latest reply on May 17, 2010 6:06 PM by mpelaez

    urgent beginner question

      Hi, I have one question, i hope someone help me


      Take a look to this example


      @Name(a)
      @Scope(ScopeType.CONVERSATION)
      class A{
       
        private Father obj;


        @In
        private B b;
       
        public void M(){
          b.getSon().setFather(this.obj);
          b.setName(Eduard);
        }


       
      }


      @Name(b)
      class B{


          private Son son;
         
      }


      the problem is that when I call the method M() works fine but if after I call  b.son appears null.
      Any idea??

        • 1. Re: urgent beginner question
          asookazian
          @Name("a") 
          @Scope(ScopeType.CONVERSATION) 
          class A{
               private Father obj;
               @In private B b; 
          
               public void M(){ 
                   b.getSon().setFather(this.obj); b.setName("Eduard"); 
               }
          
          }
          
          @Name("b") 
          class B{
               private Son son; 
          }



          what do you mean exactly by if after I call b.son?

          • 2. Re: urgent beginner question


            I mean if I have another method in class B that called oject son, for example:


            boolean M(){
            if(this.son.getName().Equals(Eduard))
               return true;
            return false;
            }


            when I call this method from presentation the object son is null even when It was created in class A.


            • 3. Re: urgent beginner question
              asookazian

              You can try to outject like this:


              @In @Out private B b;


              make sure you outject to the same context (SFSBs are conversation-scoped by default but JavaBeans are event-scoped).


              Then that instance will be available in another Seam component.

              • 4. Re: urgent beginner question
                asookazian

                or you can provide a getB() method in class A and inject A into B.

                • 5. Re: urgent beginner question

                  ok, thanks. I am going to tried that.
                  should I put to JavaBeans conversation scope??
                  B b is a ssesion bean but the object son inside b is an entity bean

                  • 6. Re: urgent beginner question

                    I do not realy like doing of that way, I prefer tried the outjection. Thanks a lot for you help and sorry for the bad english.