6 Replies Latest reply on Apr 17, 2009 8:42 PM by so38

    The Evil Page Context

    israel.bgf

      I was reading the FAQs about the page-context and now I assume that it's a very bad idea do use it for my backing-beans. So how can i use my conversation as if it was a page scope? I mean, I want to begin it when i enter the page em ends when i leave, is there any easy way to do that?

        • 1. Re: The Evil Page Context
          cash1981

          You are kidding now right?
          Aprils fool?


          Anyhow, the seam standard scope is event scope. So you will begin it when you enter the page and end it when you leave per default. It is only if you start a long running conversation that the magic of seam kicks in.

          • 2. Re: The Evil Page Context
            israel.bgf

            Err... well as far as i know the event scope begin when you enter the page and ends in the end of the request. Btw, the event scope IS the request scope of the JSF.



            Components associated with the event context are destroyed at the end of the request, but their state is available and well-defined for at least the lifecycle of the request.

            So well.. my problem is still in the air. From my point of view, now the page scope is potentially more dangerous than the session scope.

            • 3. Re: The Evil Page Context
              joblini
              From the Seam API doc:

              The page context allows you to store state during a request that renders a page, and access that state from any postback request that originates from that page. The state is destroyed at the end of the second request. During the RENDER_RESPONSE phase, the page context instance refers to the page that is about to be rendered. Prior to the INVOKE_APPLICATION phase, it refers to the page that was the source of the request. During the INVOKE_APPLICATION phase, set() and remove() manipulate the context of the page that is about to be rendered, while get() returns values from the page that was the source of the request.

              • 4. Re: The Evil Page Context
                israel.bgf

                Yah, i read that too Ingo, but the strange thing is this in the FAQ.



                From the Seam FAQ - When does the page context get destroyed?



                The page scope is indistinguishable from the UI component tree. Therefore, the page context is destroyed when JSF removes the UI component tree (also called the view) from the session. However, when this happens, Seam does not receive a callback and therefore the @Destroy method on a page-scoped component never gets called. If the user clicks away from the page or closes the browser, the page context has to wait to get cleaned up into JSF kills the view to which it is bound. This typically happens when the session ends or if the number of views in the session exceeds the limit.


                Well i tried to see the @Destroy in action in a page-context Scoped component... i opened 20 tabs in my firefox, so at least 5 views would expire (i think), but it didnt work. So for now the Page Scope look's like a session-scope that multiplies infinitely until the session expire.

                • 5. Re: The Evil Page Context
                  israel.bgf

                  So.. any ideas? Is the page context more dangerous than the session scope? What could i do?

                  • 6. Re: The Evil Page Context

                    You can control how many views are kept in the session using the following in pages.xml



                    <context-param>
                        <param-name>com.sun.faces.numberOfViewsInSession</param-name>
                        <param-value>5</param-value>
                      </context-param>
                    
                      <context-param>
                        <param-name>com.sun.faces.numberOfLogicalViews</param-name>
                        <param-value>5</param-value>
                      </context-param>




                    The glassfish wiki has a description of each of these parameters here