11 Replies Latest reply on Feb 27, 2008 12:17 PM by Pete Muir

    newbie: conversation questions

    mars1412 Apprentice

      the explanation here will be quite long, but I am sure, it took me much longer to write and that the questions are easy to answer.


      I've already read loads of docs and studied the seam-gen generated examples, but
      I'm quite stuck with that conversation thing right now


      I tried to slightly adapt the seam-gen list/edit page stuff (talking of seam-gen 2.0.0.GA), in following way:
      I do not want a separate page where the data is displayed and another page where the data is edited - I always want to go to the edit page.


      let' start with the list.xhtml page:
      I didn't change anything here - I think I understand this code, except for this:


      <s:button view="/CategoryGroupEdit.xhtml" id="create" value="Create categoryGroup">
          <f:param name="categoryGroupId"/>
      </s:button>



      question 1)
      what is the param for, if it does not have a value?
      is it to reset the parameter value to null?


      in the table I display the data and the user has a button to get to the edit page (the id is passed via a page parameter):


      <s:button id="change" value="#{messages['object.change']}" view="/private/category/categoryGroup.xhtml">
           <f:param name="categoryGroupId" value="#{categoryGroup.id}" />
      </s:button>
      



      now to the edit page:


      backing bean is categoryGroupHome which extends Entity Home - some code:


           @Factory("categoryGroup")
           public CategoryGroup initCategoryGroup() {
                return getInstance();
           }
          
           public Long getCategoryGroupId() {
                return (Long)getId();
           }
           
           public void setCategoryGroupId(Long id) {
                setId(id);
           }



      the edit page has a page.xml file (from seam-gen):


          <begin-conversation join="true"/>
            
          <param name="categoryGroupId" value="#{categoryGroupHome.categoryGroupId}"/>
           
           <navigation from-action="#{categoryGroupHome.persist}">
               <end-conversation/>
               <redirect view-id="/private/category/categoryGroup.xhtml"/>
           </navigation>
           
           <navigation from-action="#{categoryGroupHome.update}">
               <end-conversation/>
               <redirect view-id="/private/category/categoryGroup.xhtml"/>
           </navigation>
           
           <navigation from-action="#{categoryGroupHome.remove}">
               <end-conversation/>
               <redirect view-id="/private/category/categoryGroupList.xhtml"/>
           </navigation>
      



      <action execute="#{categoryGroupHome.wire}"/>



      question 2) I deleted the code above: what is it good for to call the wire function, wich is empty?


      <begin-conversation join="true"/>



      this means: everytime I call this page, a new conversation is begun (if one exists, this one is used)


      question 4) what happens, when I am on the page (conversation already exists) and I execute categoryGroupHome.persist?
      I suppose:
      after persist is called, the current conversation is ended
      then the redirect is sent to the client, which will call this page again: thus a new conversation is created immediately


      the edit page simply displays data from the categoryGroupHome object and has some buttons:


              <h:commandButton id="save" 
                            value="#{messages['object.create']}" 
                           action="#{categoryGroupHome.persist}"
                         rendered="#{!categoryGroupHome.managed}"/>                   
              ...
              <s:button propagation="end" 
                                 id="done" 
                              value="#{messages['object.done']}"
                               view="/private/category/categoryGroupList.xhtml"/>
      



      no to the main thing that I don't understand:
      When I remove the empty categoryGroupId parameter from the create button in the list page (see question 1),
      then this happens:


      I open the list page


      debug page shows no conversations


      I click create



      • url: cid=56

      • debug page: 1 conversation with id 58!



      question 5) why is that no the same as in the url


      enter some data and click 'create'



      • I am redirected to the same page again

      • url: cid=58 now

      • debug page: 1 conversation with id 58



      click 'done'



      • url: ?conversationPropagation=end&cid=58

      • debug page: no conversation



      click 'create' in the list page again



      • I see the data of the entity that I have created before



      question 6)
      how does the edit page remember the id of the new entity?



      • the conversation has been destroyed

      • the url does not include any parameters

      • the sourcecode does not include any hidden form fields with that Id



      question 7)
      has it maybe smth. todo with the s:button?


      any comments are welcome


      P.S.



      • tx for reading all this boring newbie stuff

      • did you notice that question 3 is missing :)

      • how can I nest unordered lists in this forum?






        • 1. Re: newbie: conversation questions
          Pete Muir Master

          1) yes


          2) wire() is used for entities which have ManyToOne relationships.


          4) you would need beforeRedirect="true" set on the <end-conversation /> for this to happen


          6) Using page parameters iirc

          • 2. Re: newbie: conversation questions
            Jacob SMA Newbie

            Good question Martin, I'll follow this :)

            • 3. Re: newbie: conversation questions
              mars1412 Apprentice

              since my previous posting I have read a lot about conversations in the forums.



              I think the most important thing I have missed was:



              When an @End method is encountered, any long-running conversation context is demoted to a temporary
              conversation

              That explains a lot, but I still don't know wich way to go, to implement my requirement:


              parent edit page has a conversation and the user can there click a link to get to the child edit page and back again


              does anyone maybe know an example for this?


              however: I will continue thinking/working on this one, as I think it will help me to get an understanding of seam-conversations

              • 4. Re: newbie: conversation questions
                Jacob SMA Newbie

                Yes you can use the @End tag where @Scope(ScopeType.Conversation), but what if the Scope is set to Session. Is it possible to force it to reset without exit the browser?

                • 5. Re: newbie: conversation questions
                  Pete Muir Master

                  Martin Trummer wrote on Feb 18, 2008 07:28 PM:


                  parent edit page has a conversation and the user can there click a link to get to the child edit page and back again


                  This is basically what seam-gen generates.

                  • 6. Re: newbie: conversation questions
                    mars1412 Apprentice

                    Pete Muir wrote on Feb 18, 2008 08:14 PM:


                    This is basically what seam-gen generates.


                    yes, pete that's what I took as basis for my work.



                    Martin Trummer wrote on 14. Feb 2008, 18:46 CET:

                    I tried to slightly adapt the seam-gen list/edit page stuff (talking of seam-gen 2.0.0.GA)


                    but the seam-gen'erated pages, have another intermediate page that only displays the child data and you have to click edit again to get to the real edit page.
                    I think I understand how this works, and in this case the intermediate display-only page is always used to really end the current longrunning conversation.
                    but without this displaypage I am still having some trouble


                    back to my original questions and pete's replies:


                    1) empty parameter


                    ok, I see that the page parameter is reset to &categoryGroupId=&cid=11
                    so the page parameter is cleared, but my home object in the conversation still exists - seems like setCategoryGroupId() will NOT be called in this case - why not?


                    2) empty wire function


                    I understand that it is neccessary for the child and what it does.
                    but for the parent it makes no sense - I guess, it's just because seam-gen uses the same templates for all pages


                    4) ok - I see - in the case that I described (without before-redirect=true), it would be like that:



                    1. click update button

                    2. request is sent to server

                    3. update action is invoked

                    4. navigation rule, will end the conversation and redirect to the same page again: meaning the old conversation is only demoted to a temporary conversation

                    5. page is rendered again: since the pages.xml uses begin-conversation and join=true, the old conversation (that is now a temporary one), will be resurrected and now is long-running again.



                    Is that correct?


                    If I use before-redirect=true, I will lose all the FacesMessages on my target page - is there an elegant way around that?


                    6) I don't think so pete


                    I rather think, that the problem is, that the conversation is still the same, and that the data still lives in this conversation

                    • 7. Re: newbie: conversation questions
                      mars1412 Apprentice

                      in the meanwhile after reading reference, docs forum posts and testing a lot with conversations, I think that I know understand conversations.


                      I think the following things could be improved in the docs, to help newbies getting started with the great concept of conversations:



                      • the fact, that ending a conversation demotes the long-running conversation to a temporary conversation should be emphasized in the docs or explained in more detail: maybe an explanation like 4) in my last post could really help here

                      • the difference between ending a conversation and ending a conversation before-redirect should also be explained in more detail

                      • the docs should mention, that any facesMessages are lost, when you end the conversation and use before-redirect=true (and maybe how to work around this)



                      I am well aware, that those things might be clear to other newbies, that have a J2EE background, but I think there will be many noobs like me that come from non-web development or who just start with this.


                      If you like my proposals, I could write a draft of what the documentation might be - but someone must double check, since I am still not sure, if I really got everything right (and my english is not that good)


                      BTW: questions 1) and 4) of my last post are still not clear to me

                      • 8. Re: newbie: conversation questions
                        Pete Muir Master

                        Martin Trummer wrote on Feb 19, 2008 10:19 AM:


                        but the seam-gen'erated pages, have another intermediate page that only displays the child data and you have to click edit again to get to the real edit page.
                        I think I understand how this works, and in this case the intermediate display-only page is always used to really end the current longrunning conversation.
                        but without this displaypage I am still having some trouble


                        Yes, we definitely need a chapter in the ref doc on Expanding on your generated application.




                        1) empty parameter

                        ok, I see that the page parameter is reset to &categoryGroupId=&cid=11
                        so the page parameter is cleared, but my home object in the conversation still exists - seems like setCategoryGroupId() will NOT be called in this case - why not?


                        Empty/null values aren't applied to the model.


                        2) empty wire function

                        I understand that it is neccessary for the child and what it does.
                        but for the parent it makes no sense - I guess, it's just because seam-gen uses the same templates for all pages


                        Yes.


                        4) ok - I see - in the case that I described (without before-redirect=true), it would be like that:


                        1. click update button

                        2. request is sent to server

                        3. update action is invoked

                        4. navigation rule, will end the conversation and redirect to the same page again: meaning the old conversation is only demoted to a temporary conversation

                        5. page is rendered again: since the pages.xml uses begin-conversation and join=true, the old conversation (that is now a temporary one), will be resurrected and now is long-running again.



                        Is that correct?


                        Yes


                        If I use before-redirect=true, I will lose all the FacesMessages on my target page - is there an elegant way around that?


                        No.

                        • 9. Re: newbie: conversation questions
                          Pete Muir Master

                          Open a JIRA issues for each point, and attach any improvements in diff format. Btw - no workaround for the facesMessages problems.

                          • 10. Re: newbie: conversation questions
                            mars1412 Apprentice

                            Pete Muir wrote on Feb 26, 2008 12:43 PM:


                            Open a JIRA issues for each point, and attach any improvements in diff format. Btw - no workaround for the facesMessages problems.


                            I opened one jira: I think one new chapter could clarify all those related questions:
                            improve docs for conversation propagation


                            I didn't manage to generate a diff file for the docbook-files, so I attached a text-file to the jira (I tried, XML Mind XML Editor, but it completely reformatted, the xml file - what editor/settings do you use to edit your docbook files?)



                            Yes, we definitely need a chapter in the ref doc on Expanding on your generated application.

                            A jira for this already exists:
                            Create a common "Extending Your seam-gen Application" chapter for the reference guide


                            • 11. Re: newbie: conversation questions
                              Pete Muir Master

                              Martin Trummer wrote on Feb 26, 2008 03:26 PM:


                              I didn't manage to generate a diff file for the docbook-files, so I attached a text-file to the jira (I tried, XML Mind XML Editor, but it completely reformatted, the xml file - what editor/settings do you use to edit your docbook files?)


                              Eclipse. Just tell your XML editor not to reformat under any circumstances ;-)