1 Reply Latest reply on Apr 13, 2011 5:21 AM by andrewwheeler

    context in conversation scoped

    leetong
      hi expert ! I need your help. I'm pretty new on weld.

      I'm developing a small project which has a couple of screen. For instance, login screen and search screen,
      search result screen and detail screen. They were used to be all session scoped. but we'd like to change them as conversational because users need to open multiple tabs which need to be independent from each other.

      The screen hierarchy is login->search->search result->detail..

      I'm changing search result and detail screen to conversation scoped..
      When it goes to detail screen from search result correct and it returns from detail to search result ok with all the variables in the result screen displayed...but some how after it returned to search result screen, all the variables become null...and if you click on search result screen to navigate to detail again....it gives me an empty screen on search result screen...
      When I navigate to screen, it just return name like "detail".

      Anybody can help ? When do I lose context of conversation scoped ? It does not end the conversation yet though.

      Here are two classes...SearchResultsBacking and DetailBacking

      @Named("SearchResults")
      @ConversationScoped
      public class SearchResultsBacking extends AbstractBaseBackingBean {
              private List<SearchResultTo> results;
              private HtmlDataTable dataTable;
              @Inject private Conversation conversation;

      public String begin() {
                      if (conversation.isTransient()) {
                              conversation.setTimeout(10 * 60 * 1000);

                              conversation.begin();
                      }
                      return begin(name);
              }


              public String begin(final String name) {
                      setResults(searchManager.search(name));
                      return "searchresults";
              }

          public HtmlDataTable getDataTable() {
                      return dataTable;
              }

              public void setDataTable(HtmlDataTable dataTable) {
                      this.dataTable = dataTable;
              }

             public List<SearchResultTo> getResults() {
                  if (results == null) {
                    results = searchManager.search(searchType, searchCriteria);
                   } else {
                      results = new LinkedList<SearchResultTo>();
                              }
              return results;
              }



      @Named("Detail")
      @ConversationScoped
      public class DispositionBacking extends AbstractBaseBackingBean implements Serializable {
         @Inject transient private Conversation conversation;
         @Inject private SearchResultsBacking result;
      public String begin() {
                      if (conversation.isTransient()) {
                              conversation.setTimeout(10*60*1000);
                              logger.info("current timeout {}",conversation.getTimeout());
                              conversation.begin();
                      }
      return begin((String) getValue("#{result.name}"));


      public String begin(final String name) {
                      setResult(resultManager.findByName(name)));
                      return "detail";
              }


      public void back() {
                             
                      return "searchResults";
                    
        • 1. Re: context in conversation scoped
          andrewwheeler

          You need to propagate the conversation. Try:




                      <h:button id="cancel" value="Cancel" outcome="#{Detail.back}">
                           <f:param name="cid" value="#{conversation.id}"/>
                      </h:button>