9 Replies Latest reply on Sep 13, 2006 1:11 PM by gus888

    Questions on Seam's PAGE scope

      It isn't clear how page scoped resources are cleaned up. They appear to survive multiple requests, however can be out of date and require a refresh() as indicated in the issues example ProjectFinderBean class.

      Is it possible to set a page scope timout so that resources can be cleaned up in addition to providing a way to schedule data refreshes without user interaction?

      The docs seem to imply that page scoped state is serialized back to the client, so maybe no data is being stored on the server. This might aliviate memory related issues, but having a declarative way to time out this "page cache" would seem beneficial. Am I missing a configuration option?

      An example use case might be a stock quote. A company may have an investors page that uses a third-party web service to lookup the company's stock price every 5 minutes. This request should only be made once every 5 minutes, users shouldn't be able to refresh, and it should be easy to implement. Seam + page scope + @Factory seems ideal here. If you can time out the data that is. After the time out, the factory method would be called again, and round you go.

        • 1. Re: Questions on Seam's PAGE scope
          pmuir

          I think that the PAGE scope means the context lives until the NEXT render response phase. So as long that occurs it will be cleaned up then. What happens otherwise I don't know.

          • 2. Re: Questions on Seam's PAGE scope

            So kind of an EVENT +1 request scope for a given view? I dislike not understanding this thing. I'll have to prototype it, but don't have time today. Either way it'll only tell me how it does work, not how it should work.

            Anyone in the know care to comment? School me if you will.

            • 3. Re: Questions on Seam's PAGE scope
              pmuir

              Event Scope Example:

              In Request x the user visits the page which references an outjected DataModel initialized by a Factory method. The user then clicks on a link (e.g. a detail view for a particular entity) at their leisure. In Request x + 1the state is lost and so information (e.g. entity id) must be propogated using a request parameter to allow the detail to be displayed

              Page Scope example:

              In Request x the user visits the page which references an outjected DataModel initialized by a Factory method. The user then clicks on a link (e.g. a detail view for a particular entity) at their leisure. In Request x + 1the state (of the datamodel at least) is still present in the page scope. The row clicked can then be retrieved using e.g. DataModelSelection

              This is why in the manual it says PAGE scope allows easy implementation of clickable lists. Though LIEs can occur if you work directly with the PAGE scope object in a further conversation.

              • 4. Re: Questions on Seam's PAGE scope
                gus888

                Hi Petemuir,

                Can I use the PAGE Scope SFSB in multiple same requests? e.g. DataModel category, DataModelSelection subcategory, deep looping. At this situation, the PAGE Scope SFSB is similar to Conversation Scope SFSB, is it correct? Thank you in advance.

                • 5. Re: Questions on Seam's PAGE scope
                  pmuir

                  I don't really follow you sorry. You could describe PAGE scope as a mini-conversation that spans a single Request-Response-Request cycle. If you are asking whether the PAGE scope can be used to achieve a multi-level Master-Detail view architecture, then yes I suppose it could, but a long running conversation would probably be more useful.

                  For example I use PAGE scope to implement a clickable list where the click takes the user to another view and there is no need to retain any state (other than the item clicked) from the list screen.

                  • 6. Re: Questions on Seam's PAGE scope

                    Thanks Pete. This clears things up for me.

                    • 7. Re: Questions on Seam's PAGE scope
                      gus888

                      Hi Petemuir,

                      Thank you for your reply. I have a categories list in jsf page. @DataModel List categoryList, @DataModelSelection Category selectedCategory. When click one category, the page will list subcategory list, then click a subcategory, it will display sub-subcategory list .... Currently, I use SESSION Scope SFSB. I have a problem with the browser BACK. That is, when I click a category on supcategory list, the page displays its subcategory list. However, when I click browser BACK, the page was back to supcategory list. When I try to click another category on the supcategory list, the page will not display the subcategory list which I just clicked, but it went to the subcategory list which I previously clicked, I don't what is wrong with my SESSION Scope SFSB. Thank you for your help in advance.

                      • 8. Re: Questions on Seam's PAGE scope
                        gavin.king

                        PAGE scope objects are essentially never cleaned up!

                        Why? because they live on the client side! The user can at any time backbutton to the page and click on one of its buttons.

                        So PAGE scope has an indeterminate lifetime (but still a welldefinined extent).

                        (Thats why you can't put SFSBs in the PAGE context - they would never be cleaned up.)

                        HTH

                        • 9. Re: Questions on Seam's PAGE scope
                          gus888

                          Thank you very much, Gavin and Petemuir. I got more clear.