6 Replies Latest reply on Feb 13, 2006 1:57 PM by gavin.king

    @Factory problem

    emsa

      I have this:

      @In(create = true)
      private InObj inObj;
      
      @Out
      private OutObj outObj
      
      @Factory("outObj")
      public void init() { .. }
      
      public String action() [ ... }
      


      The inObj is a Session object.

      When accesing 'outObj' from a page the Factory method is called as expected with a value assiged to inObj.

      But when calling the action() method from a page the Factory method is called again but the inObj is null. This will cause my init() method to throw, Seam catched the exception and logs it and then Seam calls my action() method but with a value injected into the inObj and the correct page is shown.

      This seams like a bug to me but maybe I'm not using the Factory pattern correctly?

      /Magnus



        • 1. Re: @Factory problem
          gavin.king

          Well, the combination of @In and @Factory is working in all the examples.

          And I would not have expected @Factory to be called when you are calling an action method. Why would it be called?

          • 2. Re: @Factory problem
            emsa

             

            "gavin.king@jboss.com" wrote:
            Why would it be called?


            Well - you tell me :-)

            I did the following test - I added a @Factory in HotelBookingAction.java, like this:

            @Factory("hotels")
            @Begin(join=true)
            public String find() {
             ... }
            


            This result in that the find() method is called twice when 'posting' for hotels from the main page in the booking app. The find() method is called once when entering the page without posting - this is what happens in my app as well ...

            /Magnus



            • 3. Re: @Factory problem
              emsa

              Gavin this cannot be a correct behaviour?

              It seems like the factory method is called at the start of the cycle before the action method is called. Shouldn't the the factory method be called at the end of the cycle if the requested context-variable is still null after the action invokation?

              /Magnus

              • 4. Re: @Factory problem
                gavin.king

                I don't see why the @Factory method should be called at all. But then, you have not show us enough code for me to really be able to make that call...

                • 5. Re: @Factory problem
                  emsa

                  Is there anything special you'd like to see? Please note that adding @Factory as above in this thread create a call to the factory method.

                  • 6. Re: @Factory problem
                    gavin.king