7 Replies Latest reply on Jul 13, 2007 7:51 AM by rapowder

    conversations join/nest

    rapowder

      Hi,

      In my application (Seam 1.2.1GA) I use 2 level of nested conversations to navigate across categories, subcategories and items of each subcategory. That's my scenario:

      Bean 1 (select a category) -> Root Conversation
      Bean 2 (select a subcategory) -> Nested inside the root
      Bean 3 (edit an item of the subcategory) -> Nested inside the previous

      When I switch between categories the subcategories are updated, when I click on a subcategory I see the respective items, and when I click on an item I can edit its properties. In order not to create a new (or new nested) conversation each time I switch cat, subcat or item I have written this method (called in the @Factory methods of my backing beans) to always join the correct level of conversation.

       public void joinSameOrNest(Class caller) {
       Conversation current = Conversation.instance();
       boolean started = false;
       for (ConversationEntry entry : ConversationEntries.instance().getConversationEntries()) {
       if(entry.getDescription().equals(caller.getName())) {
       entry.select();
       log.info("Joining conversation " + caller.getName());
       current.begin(true, false);
       started = true;
       }
       }
       if(!started) {
       log.info("Starting nested conversation " + caller.getName());
       current.beginNested();
       }
       }
      


      I recognize the level of conversation since, in the @Factory methods of my backing beans I first call the method:

       public void setDescription(Class caller) {
       Conversation.instance().setDescription(caller.getName());
       }
      


      Until the first level of nesting it works fine and in the conversation stack I always see the root and the nested, but when I try to edit an item (starting the 2nd level of nesting) I get an exception:

      java.lang.IllegalStateException: beginNested() called with no long-running conversation


      Is it actually possible to have multiple nesting? Is something wrong in my method? I was using the annotations before @Begin(nested/join), but a limited behaviour can be achieved with that. Or am I wrong?

      Thanks for any suggestions!
      Cheers