4 Replies Latest reply on Apr 5, 2009 6:37 AM by oyesiji77

    Accessing Factory from other Classes

    oyesiji77

      I have defined a factory



      @Out(required=false)
           protected List<SelectItem> jobCategorySelectService;
      
      @Factory("jobCategorySelectService")
           public void loadJobCategoryForDropDown() {
      jobCategorySelectService=.........
      ......




      }
      Though i can access this Factory component on an xhtml Page, Please how do i access this from another Class

        • 1. Re: Accessing Factory from other Classes
          gonorrhea

          Assuming your Seam component is conversation-scoped (which is default for SFSB), then jobCategorySelectService will be outjected to conversation context and will be available for injection during the conversation.


          The key is bijection (injection + outjection + disinjection).  You outject from component A to scope X and inject that variable into component B.

          • 2. Re: Accessing Factory from other Classes
            oyesiji77

            when i injected the Factory jobCategorySelectService in my other component, I discovered it was null by the way jobCategorySelectService  is application Scoped



            public class Component2{

            @In("#{jobCategorySelectService}")
                  List<SelectItem> jobCategorySelectService;


            }

            • 3. Re: Accessing Factory from other Classes
              gonorrhea

              application scope is the broadest scope in Seam.  Was it ever set to something other than null prior to the outjection?  Once an object is set to a non-null value in application scope, then it will be available until the app server is restarted unless it is set to null during the course of the app.


              Also, typically when you inject, you simply use @In.


              @In("#{jobCategorySelectService}) is most likely wrong syntax.


              In this case @In is equivalent to @In("jobCategorySelectService").


              Seam defaults to the instance name of the injected object if you don't specify it.

              • 4. Re: Accessing Factory from other Classes
                oyesiji77

                Its working now thanks made a mistake about the Scope