5 Replies Latest reply on Mar 16, 2009 11:41 PM by agurisatti

    Application runnig in two tabs get messed up

    agurisatti

      Hi,


      Im using Seam 2.1.1 and have a big problem when opening an application in two Firefox tabs:


      The problem is that when you start the application you select three objects: Structure, unit and plan. As they are heavily used, I dont want to be forced to select them in each menu option I use. The only way I found to achieve this was to put them in session scope. As a result if I open the application in two tabs, selecting one of this objects (structure, unit or plan) in any of them creates a real mess as they get selected for both tabs.


      Could any one help me out with this with some idea? The point is how can I get an object available for all options in the application without using Session scope?


      Thanks in advance for any help. I can't get out to production until this issue gets solved.




        • 1. Re: Application runnig in two tabs get messed up
          niox.nikospara.yahoo.com

          Hello,


          I believe that is one of the problems that SEAM conversations solve. Read about them in the docs, I think it is what you want.

          • 2. Re: Application runnig in two tabs get messed up
            agurisatti

            Hi Nikos


            Thanks for your answer.


            The problem is that this three pieces of data (structure, unit and plan) are used all over the application. In this case, I should have to put all the application in a huge conversation and I think it would create a great number of problems (Starting by the fact that Seam, by default, commits transactions to database at the end of the conversation).


            By the way, I have the book JBOSS in Action by Jamae and Johnson. Its a really great book!!


            So, if some one has another idea, please let me know.


            Thanks in advance,
            A. Gurisatti 

            • 3. Re: Application runnig in two tabs get messed up
              gonorrhea

              in this case, I would use conversation-scoped JavaBean or SFSB as backing beans for your xhtml file(s).


              How is the data for those 3 objects being populated?  db read, etc.?


              If it's db read, then I recommend using @Factory/@DataModel combo to populate a list and outject to conversation-context.  The extra db hits is not a concern when you use @Factory b/c the method that is associated with the @Factory is only executed when the List associated with @Facotry is null (i.e. that method will only get exec'd once per session unless the List object is explicitly set to null).


              look at the hotel booking example (it works with multiple windows/tabs) and read Seam in Action and/or the new Yuan Seam book (2nd ed.)


              BTW, it's Seam - not SEAM.  It's not an acronym, it's a concept....

              • 4. Re: Application runnig in two tabs get messed up
                gonorrhea

                actually there's two situations in which the @Factory method will get called more than once per session:


                1) when the List object is set to null
                2) when the @Factory method is called explicitly

                • 5. Re: Application runnig in two tabs get messed up
                  agurisatti

                  Hi Ron,


                  Thanks for your answer.


                  The three pieces of data are selected in a page that includes that purpose and sent to Session context using:



                       @In(required = false, create = true)
                       @Out(required = false, scope = ScopeType.SESSION)
                       private OrganizationalStructure selectedOrg;
                       
                       @In(required = false)
                       @Out(required = false, scope = ScopeType.SESSION)
                       private OrganizationalUnit selectedUnit;
                  
                       @In(required = false, create = true)
                       @Out(required = false, scope = ScopeType.SESSION)
                       private StrategicPlan selectedPlan;
                  



                  The they are injected in all beans that need the piece of data.



                       @In
                       private OrganizationalStructure selectedOrg;
                  
                  


                  And there are a lot of beans that get these data injected. It would be really awfull to force the user to select these three entities each time he enters a page.



                  By the way, while it is true that I have the JBoss in Action book (it was a oooops), I really ment to say I have (and studied) the book JBoss Seam by Michel Juntao and Thomas Heute and it is also a great book!!


                  Thanks a lot,
                  Antonio Gurisatti