4 Replies Latest reply on Jul 22, 2009 6:46 PM by Jubril Adisa

    Method annotated with @Create executes Multiple Times in a Long Running Conversation

    Jubril Adisa Novice

      I started a Nested Transaction on going from Page A to Page B. In Page B the Backing bean has a @create Method



      public class D{
      
              @Create
              public void load(){
                      System.out.println(">>>>>>>>>"+user.getUserName());
                      files = new ArrayList<File>();
                      
              }
      
      }
      




      But I discovered that when I declare D with scope CONVERSATION. The load method executes multiple times, but when i use Session it executes once, Is the Conversation Scope not suppose to be once, if i don't end the conversation

        • 1. Re: Method annotated with @Create executes Multiple Times in a Long Running Conversation
          Arbi Sookazian Master

          How are you managing conversations in your use case?  Typically we use @Begin(join=true).  In your case, it may be @Begin(nested=true).


          I don't see any @Begin in your class so I'm assuming you don't have a LRC running.  In Seam apps, there is always a temporary conversation, but the temporary conversation may be promoted to a LRC declaratively or programmatically (see the Seam ref doc for more on this).


          If you don't have a LRC, then this D component will be destroyed after each method call (in fact, you can add an @Destroy public void destroy() { log.info("destroyed!"); } to prove this.


          Also, be aware that this POJO needs a @Name annotation to make it a Seam component so it gets installed into the Seam container when the app is deployed.

          • 2. Re: Method annotated with @Create executes Multiple Times in a Long Running Conversation
            Jubril Adisa Novice

            Arbi Sookazian wrote on Jul 22, 2009 05:48:


            How are you managing conversations in your use case?  Typically we use @Begin(join=true).  In your case, it may be @Begin(nested=true).

            I don't see any @Begin in your class so I'm assuming you don't have a LRC running.  In Seam apps, there is always a temporary conversation, but the temporary conversation may be promoted to a LRC declaratively or programmatically (see the Seam ref doc for more on this).

            If you don't have a LRC, then this D component will be destroyed after each method call (in fact, you can add an @Destroy public void destroy() { log.info("destroyed!"); } to prove this.

            Also, be aware that this POJO needs a @Name annotation to make it a Seam component so it gets installed into the Seam container when the app is deployed.


            I am using the components.xml File, there I have



            <component name="B" class="com.testing.action.B" scope="CONVERSATION"></component>


            and before i navigate to B I always start a nested Long running conversation




            <rule if-outcome="B">
             <begin-conversation flush-mode="manual" nested="true" id="B"></begin-conversation>
               <redirect view-id="/B.xhtml"/>
            </rule>






            Click HELP for text formatting instructions. Then edit this text and check the preview.

            • 3. Re: Method annotated with @Create executes Multiple Times in a Long Running Conversation
              Arbi Sookazian Master

              from SiA book:



              In effect, the name attribute is the role name. You may find the <component> declaration to be more suitable for defining roles than the @Role annotation,
              as I have.

              So your rule (rule if-outcome portion) is checking for a String returned from an action method equivalent to B and that's not happening.  B is a role, not an outcome in String format.


              I'm not sure you're implementing this correctly.


              You should consider using a @Startup with @Create method instead for a SESSION or APPLICATION-scoped component.  Also, remember that you can't debug XML in your IDE's debugger, so that's a disadvantage.


              But even that may be wrong b/c that may start the LRC too early.


              Why can't you just use annotations (@Begin) in your backing bean and start the LRC exactly at the time (i.e. correct action method when user click button, etc.) you need to?


              It seems to me that you're making this too complicated by declaring the component in the components.xml.  And remember that components declared in components.xml are not incrementally hot deployable (if they are JavaBeans).


              Determine when the root LRC and nested LRC needs to start and end and then determine if you're going to use annotations, code via Conversation API (e.g. Conversation.begin()), or pages.xml to begin and end the conversations.  Very simple (unless, of course, you have a complex use case/page flow).

              • 4. Re: Method annotated with @Create executes Multiple Times in a Long Running Conversation
                Jubril Adisa Novice

                I discovered the problem, its not to do with my code or conversation, it has everything to do with the rich:upload i am using






                http://www.seamframework.org/Community/RichfileUploadListenerIsJumpingOutOfTheConversation





                For some reason the upload button is ending the current Transaction and starting a new One