1 Reply Latest reply on Oct 20, 2009 8:29 AM by Pulkit Mehra

    Custom ID in Nested Cobversation

    Pulkit Mehra Newbie

      Hi Friends,



      I  am working on concurrent conversation. I am facing some problem in generating nested conversation with custom ID .


      My Session bean starts a conversation :




      @Stateful
      @Name("CalcOne")
      @Scope(ScopeType.SESSION)
      public class CalcContestBean implements CalcContext{
      
      /*
      * (2) method called by UI to start a nested Conversation
      */
      public String startViewCalendar(){
      //I get instance of Conversation bean where i want to start a nested ocoversation        
      
      CalcTwoContext cal=(CalcTwoContext)Component.getInstance("CalcTwo",true);
      Contexts.getConversationContext().set("userInconversation","myID");
      
      //(3) : code to be inserted as tweak
      
      cal.startViewCalendar();
      return "";
      }
      
      /*
      *  (1) method to start parent conversation
      */
      @Begin(id="parent" , join=true)
      public String showAttendees(){
        return "";
      }
      
      @End
      public String hideAttendees(){
        return "";
      }
      
      }



      I call (1):showAttendees to start a parent conversation which results in a conversation with id parent and than i call (2):startViewCalendar to start a nested conversation with id myId.
      I am not able to start a nested conversation with myId.Seam generates its own conversation id which hinder my logic.


      In order to generate myId i need to put following code at (3):startViewCalendarn which creates conversation but kills nesting.




      if(Conversation.instance().isLongRunning()){
                        Conversation.instance().leave();
                    } 



      My Conversation bean is :



      @Stateful
      @Name("calcTwo")
      @Scope(ScopeType.CONVERSATION) 
      public class CalcTwoBean implements CalcTwoContext
      
      @End
      public String endViewCalendar(){
              return "";
          }
      
      
       @Begin(id="#{userInconversation}",nested = true)
       public String startViewCalendar(){
      log.info("Conversation {0}",Conversation.instance().getId());   
        return "";
       }                                       
      }




      Thanks in Advance,


      Pulkit