1 2 Previous Next 15 Replies Latest reply on Feb 19, 2011 8:14 PM by qixunyuan

    Seam Conversation & Multiple Windows

    holgerprause Newbie

      Hello.


      I noticed seam supports multiple browser windows / tabs via the conversation model and the s:link tag.
      Now my idea is to use seam to support multiple popup windows, that means instead opening a new tab i display the content in a popup window.


      Well i think ill neeed to start a new conversation for each window opened.
      That i can do with the @Begin annotation.


      But somehow ill need to associate the popup window with the conversation.
      Which leads me to the conclusion that i need a named conversation.(mabye sth like Coonversations.start(myConversationName))


      Arent seam task named conversations - maybe the ill need to do some research how to work with them.
      Does this making any sense to you?
      I am very new to seam conversations.


      Thx very much for any help / suggestions

        • 1. Re: Seam Conversation & Multiple Windows
          Leo van den berg Master

          Hi  Holger,


          If I understand your question well you want to use different windows for the same session. This is supported out-of-the-box without anyy effort from your side. When you use the s:link tag  the conversation is automatically added and used in your new window.


          You can also have multiple converations and switch fom one to the other.The way to use this is explained very well in the documentation. The seam distribution has a complete range of simple and more complex examples which you could use to cut-and-paste your application together.


          You could also use the Seam in Action book from Manning. This book goes in more detail in how to do this.


          Good luck!


          Leo


          • 2. Re: Seam Conversation & Multiple Windows
            holgerprause Newbie
            Hi well i failed again explaining my issue.

            Well what works out of the box is using different (browser)windows for the same session.
            Well what i want to do is using different _pop-up_ windows for the same session.

            That means instead having multiple browser windows/tabs i want to have  multiple popup-windows in the same browser window.
            From my point of view its the same like having multiple browser windows - only the presentation is different.

            The problem i run into with this approach is that i dont know which conversation belongs to which popup window(and reacting on action from that popup-window becourse they all belong to the same browser window / conversation).
            So i thought i need "named" conversation and to associate them with my popup window.

            But too much is unclear to me right now.I just want to know if my idea could be realized with seam
            "You can also have multiple converations and switch fom one to the other.The way to use this is explained very well in the documentation."

            Well thx for your advise ill take a look into seam workspace management.

            • 3. Re: Seam Conversation & Multiple Windows
              Leo van den berg Master

              Ok,


              now I get your point, I think it should work perfectly because all pop-ups originate from the same session. The only problem I see is if you want to use the same component in the different windows. In that case you should define different roles for each component.


              I have repeated this simple butr very effective trick a number of times. Put simple logging in create and destroy methods. In this way you can see what is happening under the hood. Seam is very aggresive in its management of instances and it deletes an out-of-scope component in a sec. Logging helps detecting this behaviour.


              Success,


              Leo 

              • 4. Re: Seam Conversation & Multiple Windows
                holgerprause Newbie

                Hi, thx for your time and your reponse.



                now I get your point, I think it should work perfectly because all pop-ups originate from the same session.

                I think that too.



                The only problem I see is if you want to use the same component in the different windows

                I get around this with a custom form renderer.



                The only problem i got is - like i already said , giving each window an own conversation and associating with it.



                @In
                @Out
                Person person
                ..
                ..
                ..
                @Begin
                public String loadPerson(person_id) {
                   person = myDataBase.find(Person.class, person_id);
                }
                
                public void debugCurrentPerson() {
                  log.info("current person: "+person);
                }
                




                now from my view(in a popup window)
                <a4j:commandLink action="#{MyBean.debugCurrentPerson}"
                
                -> i have 2 popup window 
                -> if i click on this link from 2 popup windows - both actions outputs the same username(the last loadded person) 
                but it should be 2 different persons , 1 for each popup(conversation).
                



                I think that becourse both objects were loaded from the same browser window and are associated with the same conversation?
                That where i have understanding problems.


                Do i need to tell my a4j:commandLink explicitly which conversation to use and how to do this?


                Thx very much



                • 5. Re: Seam Conversation & Multiple Windows
                  Leo van den berg Master

                  Holger,


                  you should give the component a conversation scope and be sure that there are different conversations attached to each popup. Seam should give each windoww its own instance of the component.


                  Leo

                  • 6. Re: Seam Conversation & Multiple Windows
                    holgerprause Newbie

                    Hi



                    and be sure that there are different conversations attached to each popup

                    Thats my big problem becourse i dont know how to do this.All my object seems to be in the same conversation.
                    Can u give me some hint or (pseudo) code how to archiev this(or some hint where to read about this)?



                    Seam should give each windoww its own instance of the component.

                    That would be wonderfull!


                    thx very much

                    • 7. Re: Seam Conversation & Multiple Windows
                      Leo van den berg Master


                      On your component:
                      
                      @Scope(ScopeType.CONVERSATION)
                      
                      and
                      
                      @Begin(nested=true)
                      
                      



                      You can do the same from a page definition or directly in the s:link -tag.


                      Leo

                      • 8. Re: Seam Conversation & Multiple Windows
                        holgerprause Newbie

                        Ill give it a try- thx for helping me understanding conversations.
                        Its good to know that what i am trying to do is possible and supported(theoretically) by seam.


                        • 9. Re: Seam Conversation & Multiple Windows
                          holgerprause Newbie

                          Thx Leo!
                          Hi - well i think i understood it now - what i have achieved


                          1) open multiple popupwindow(its an overlay) on the page
                          2) start a conversation for every popupwindow
                          3) switch between conversations with seam workspace management (only for testing and understanding)



                          Now theres only 1 thing to do :
                          How do i tell my a4j:commandLink which conversation he should use?(not the current one - remember we have multiple popup-windows opened at this time and every one has its own conversation - which is just great)
                          Speaking more general i need to tell my my jsf action what conversation to use(the one which was started for this popup-window and in which the command link is).


                          Can u give me hint on this or where to find information on this.
                          Thx very much until here, you really helped me a lot.

                          • 10. Re: Seam Conversation & Multiple Windows
                            Leo van den berg Master

                            Hi Holger,


                            You can switch between conversations (workspaces), and use a select bos to switch between the available ones. 



                            I've have a prototype somewhere, but I am not at the office right now, so i can't look it up. But it should be explained in the documentation.


                            Leo

                            • 11. Re: Seam Conversation & Multiple Windows
                              Arbi Sookazian Master

                              popups in Seam are usually rich:modalPanel components and thus you can't show more than one popup simultaneously.


                              See my recent thread about multiple modalPanel forms and submissions and persistence, etc.  It gets complicated when you have multiple forms in one LRC that are updateable/insertable...

                              • 12. Re: Seam Conversation & Multiple Windows
                                holgerprause Newbie

                                Hi



                                rich:modalPanel components and thus you can't show more than one popup simultaneously.

                                Becourse of that i wrote my own popup component and it works pretty well.
                                Now i want to have multiple of that popups and associate them with a conversation.


                                It works with multiple forms etc(got a custom form and vie renderer) only missing thing is telling my commandLink
                                in which conversation they are
                                so they dont take the last active.

                                • 13. Re: Seam Conversation & Multiple Windows
                                  holgerprause Newbie

                                  only missing thing is telling my commandLink in which conversation they are

                                  just put <s:conversationId /> on the a4j:commandLink.



                                  All fine now - thx for your help and suggestions - helped me finding this solution


                                  • 14. Re: Seam Conversation & Multiple Windows
                                    Stefano Zaccaria Newbie

                                    Hi Holger, nice post!
                                    I've the same problem, unfortunately I do not know how you did it to start different conversations for different windows, can you give me some snippet of code?
                                    Thanks in advance.

                                    1 2 Previous Next