1 2 Previous Next 19 Replies Latest reply on Mar 4, 2008 4:42 AM by matt.drees Go to original post
      • 15. Re: Injection And Child Objects
        tom_goring

        Hi,


        Yes that does work but it's not what Pete suggested I think.


        Is it the case then you should never store a reference to a Seam object.  i.e. only use injection...



        Workaround is to rather than store the parent reference in the PojoChild look it up every time it is required. PojoChild in my case is like a utility class that can add functionality to the parent... Doing the look up or using injection makes the utility more cumbersome as it does not know the parent seam component name at runtime (and so this would have to be passed in).
        • 16. Re: Injection And Child Objects
          pmuir

          Tom Goring wrote on Feb 27, 2008 03:30 PM:



          Is it the case then you should never store a reference to a Seam object.  i.e. only use injection...



          Yes, basically. Whilst in the same request it should be ok though. Certainly safer to always use lookup in the child.

          • 17. Re: Injection And Child Objects
            matt.drees

            Hmm.


            And you're also doing


                 public PojoChild getPojoChild() {
                      if ( pojoChild==null ) {
                           System.out.println("creating pojo");
                           this.pojoChild = new PojoChild(instance());
                      }
                      return pojoChild;
                 }
            
            ...
            
                 public static SeamParent instance() {
                   return (SeamParent)Component.getInstance("seamParent");
                 }
            


            as Pete said, right? If so, then I think that should work.

            • 18. Re: Injection And Child Objects
              tom_goring

              Hi,


              Yes I tried that.... it does not work.


              It only works if you look you look up the SeamParent from the PojoChild every time it is required.... i.e. you can't store any kind of reference to it. 


              This is a bit of a shame for me as I was planning small utility classes (e.g. action handler classes) to work with the parent.... The only way this works is if I look up the parent every parent is required. 


              • 19. Re: Injection And Child Objects
                matt.drees

                You're right, you're right.


                The culprit here is the org.jboss.seam.core.MethodContextInterceptor, which, during the execution of a component's method (such as create() above), makes it impossible to obtain a reference to that component's proxy object.



                It turns out there is a jira issue for this: JBSEAM-2221.  So, maybe go ahead and vote for that issue.  It's something that I think needs to be added to Seam, too.

                1 2 Previous Next