9 Replies Latest reply on Jan 10, 2008 4:37 PM by Chris Simons

    Data disappeared when clicking on Conversation outjection pa

    Gus Gu Expert

      Hi there,

      I have a stateless session bean which has a conversation outjection page:

      @Name("contactServicer")
      @Stateless
      @Scope(ScopeType.STATELESS)
      public class ContactServicerBean implements ContactServicer {
      
      
       @Out(required=false, scope=ScopeType.CONVERSATION)
       private List<Email> emailList;
      
       @Out(required=false, scope=ScopeType.CONVERSATION)
       private List<Phone> phoneList;
      
       ....
      }

      Question 1: I tried different outjection scopes: EVENT, PAGE and CONVERSATION, and only the CONVERSATION scope works (outjected data were displayed on web). When I used EVENT and PAGE scopes, no data were displayed on web page. I don't know why?
      Question 2: When I clicked h:commandLinks of individual email and phone, the whole page data disappeared. Anybody can explain why? Thank you in advance.

        • 1. Re: Data disappeared when clicking on Conversation outjectio
          Gus Gu Expert

          Anybody can give a help? I am looking for Seam pattern for browsing data and pagination. Thank you very much.

          • 2. Re: Data disappeared when clicking on Conversation outjectio
            Jacob Orshalick Apprentice

             

            "gus888" wrote:
            Question 1 : I tried different outjection scopes: EVENT, PAGE and CONVERSATION, and only the CONVERSATION scope works (outjected data were displayed on web). When I used EVENT and PAGE scopes, no data were displayed on web page. I don't know why?


            What is the rest of the scenario? How are these values getting populated? Are you executing an action then redirecting?

            "gus888" wrote:
            Question 2 : When I clicked h:commandLinks of individual email and phone, the whole page data disappeared. Anybody can explain why? Thank you in advance.


            Have you started a long-running conversation? Data outjected to conversation scope will be outjected to the temporary conversation which is destroyed at the end of the request if you don't promote the conversation to long-running.

            • 3. Re: Data disappeared when clicking on Conversation outjectio
              Gus Gu Expert

               

              "jacob.orshalick" wrote:
              "gus888" wrote:
              Question 1 : I tried different outjection scopes: EVENT, PAGE and CONVERSATION, and only the CONVERSATION scope works (outjected data were displayed on web). When I used EVENT and PAGE scopes, no data were displayed on web page. I don't know why?


              What is the rest of the scenario? How are these values getting populated? Are you executing an action then redirecting?

              Hi Jacob, thank you for your reply.
              I follow Seam wiki pagination sample: manage bean is stateless bean, outject a event or page scope page, but I don't know why I didn't get results back to page. Only after I used conversation outjection, I can got results displayed on page. However, when I try to click a link on the page, the results on the page disappear immediately. I really feel frustrated.

              "jacob.orshalick" wrote:

              "gus888" wrote:
              Question 2 : When I clicked h:commandLinks of individual email and phone, the whole page data disappeared. Anybody can explain why? Thank you in advance.


              Have you started a long-running conversation? Data outjected to conversation scope will be outjected to the temporary conversation which is destroyed at the end of the request if you don't promote the conversation to long-running.
              I did not use a long-running conversation. I use stateless bean to outject a temporary conversation. Is it correct? Thank you very much.

              • 4. Re: Data disappeared when clicking on Conversation outjectio
                Jacob Orshalick Apprentice

                 

                "gus888" wrote:
                I follow Seam wiki pagination sample: manage bean is stateless bean, outject a event or page scope page, but I don't know why I didn't get results back to page. Only after I used conversation outjection, I can got results displayed on page. However, when I try to click a link on the page, the results on the page disappear immediately.


                Without some code (the view, the navigation, etc), I don't think anyone is going to be able to help here...

                "gus888" wrote:
                I did not use a long-running conversation. I use stateless bean to outject a temporary conversation. Is it correct? Thank you very much.


                If you outject to the conversation, you must begin a long-running conversation to have the data available on the next request (the next click of a commandLink). Otherwise, the temporary conversation will be destroyed and your data is gone on the next request.

                • 5. Re: Data disappeared when clicking on Conversation outjectio
                  Gus Gu Expert

                   

                  "jacob.orshalick" wrote:
                  Without some code (the view, the navigation, etc), I don't think anyone is going to be able to help here...

                  Thank you, Jacob. Following are my code snippets:
                  pages.xml
                  <page view-id="*">
                   <navigation>
                   <rule if-outcome="emailList">
                   <redirect view-id="/emails.xhtml"/>
                   </rule>
                   <rule if-outcome="phoneList">
                   <redirect view-id="/phones.xhtml"/>
                   </rule>
                   ....
                  
                  sidebar.xhtml
                   <div>
                   <ice:commandLink value="Contact Emails"
                   action="#{contactServicer.retrieveEmails}"/>
                   </div>
                  
                   <div>
                   <ice:commandLink value="Contact Phones"
                   action="#{contactServicer.retrievePhones}"/>
                   </div>
                   ...
                  
                  emails.xhtml
                   <ice:panelSeries style="clear: both;"
                   value="#{emailList}"
                   var="email" rendered="#{!empty emailList}">
                   <div class="row">
                   <ice:outputText value="#{email.emailAddress}"/>
                   </div>
                   ....
                  
                  phones.xhtml
                   <ice:panelSeries style="clear: both;"
                   value="#{phoneList}"
                   var="phone" rendered="#{!empty phoneList}">
                   <div class="row">
                   <ice:outputText value="#{phone.phoneNumber}"/>
                   </div>
                   ....
                  
                  @Name("contactServicer")
                  @Stateless
                  @Scope(ScopeType.STATELESS)
                  public class ContactServicerBean implements ContactServicer {
                  
                  
                   @Out(required=false, scope=ScopeType.CONVERSATION) //EVENT and PAGE don't work
                   private List<Email> emailList;
                  
                   @Out(required=false, scope=ScopeType.CONVERSATION) //EVENT and PAGE don't work
                   private List<Phone> phoneList;
                  
                  
                   public String retrieveEmails() {
                   emailList = em.createNamedQuery("...").getResultList();
                   return "emailList"
                   }
                  
                   public String retrievePhones() {
                   phoneList = em.createNamedQuery("...").getResultList();
                   return "phoneList";
                   }
                  
                   ....
                  }
                  

                  "jacob.orshalick" wrote:
                  If you outject to the conversation, you must begin a long-running conversation to have the data available on the next request (the next click of a commandLink). Otherwise, the temporary conversation will be destroyed and your data is gone on the next request.
                  I don't know which pattern is good for enterprise project based on my codes above. Seam wiki pagination sample is using Stateless bean + Event outjection, but I couldn't make this work.

                  • 6. Re: Data disappeared when clicking on Conversation outjectio
                    Jacob Orshalick Apprentice

                    I believe scoping to the PAGE would make sense in your case. Outject to the PAGE *after* the redirect is performed. One way to do this is using @Factory on your retrieveEmails() and retrievePhones() and changing your s:link to refer to the view directly. Take a look at the documentation on Page context to understand the whys here: http://docs.jboss.com/seam/2.0.1.CR1/reference/en/html/concepts.html

                    "gus888" wrote:
                    I don't know which pattern is good for enterprise project based on my codes above. Seam wiki pagination sample is using Stateless bean + Event outjection, but I couldn't make this work.


                    The pattern is up to you. Seam gives you choices. There are cases where I have used each of the contexts you have mentioned, it simply depends on the scope that the data is needed for.

                    • 7. Re: Data disappeared when clicking on Conversation outjectio
                      Chris Simons Expert


                      Jacob,

                      Are you suggesting that conversation outjection works differently when an s:link points to a view (ex. view.jsf) versus a bean method (ex. bean.view)?

                      This would explain a lot of problems we are having with conversations in a very complex system we are working with. We are on Seam 2.0 and JBoss 4.2.2.

                      We're losing conversational objects between redirects and we can't figure out. Suggesting that the above does work differently would really limit the usage of pages.xml, wouldn't it?

                      • 8. Re: Data disappeared when clicking on Conversation outjectio
                        Jacob Orshalick Apprentice

                        No, the suggestion I posted is not referring to conversation handling, I'm simply offering an option if the original poster wants to use PAGE context (which is what the original post referred to).

                        The only difference in an s:link between pointing to a view-id and an action is that an action gets executed in one case and not the other. The conversation propagation behaves the same...

                        "chris.simons" wrote:
                        We're losing conversational objects between redirects and we can't figure out.


                        If you post information about your scenario in another thread we will do our best to help you out.

                        • 9. Re: Data disappeared when clicking on Conversation outjectio
                          Chris Simons Expert

                          Jacob,

                          Thanks for the quick reply.

                          We're discussing things internally; I may put together a post on our issues but I fear it will get to be too lengthy for any forum post.

                          In short, our issues deal with conversation propagation, handling conversational elements between stateful session beans, and why sometimes we are having to manually lookup entities from the entityManager when they should instead be accessible from our conversation stack.

                          We plug one hole only to open up another. It's getting quite frustrating. From reading this forum, I feel there are a lot of confused users out there in regards to conversation handling.

                          I understand this really isn't anything to go by - I'll try to put together something more succinct tomorrow in case you're around. :)

                          I appreciate your time.