3 Replies Latest reply on Jul 31, 2008 1:28 PM by holan

    how to decide page's scope which has h:dataTable in it?

    holan

      I use seam and I found the booking example has one problem.It use the ScopeType.Session as the HotelSearchAction's scope.So if a user click a table item.the jsf life cycle will not re-initialize the HotelSearchAction.
      (mostly often,if I use pojo,I just use request Scope,so if user click a table item. The jsf life cycle will re-initialize the pojo, and if the pojo has a dataModel, it will query the dataBase in the apply-request phase and the render-response phase,so it query the database twice).
      But if I use ejb Stateful bean. cause the bean is stateful,so it will not query the dataBase in the apply-request phase.This sollution is good.
      But here comes the problem.What scope should the stateful-bean has?
      If I use ScopeType.Session.(this is the booking example use).obviously there will be a memery-leak.If I have a lot of page which has a table,It will take a lot of memery.
      Should I use a ScopeType.Conversation.And decide the @begin and @end to limit the memery use?
      What is the Common Style to handle the h:dataTable involved Problem?It means Don't query the dataBase twice( in the apply-request and the render-respoonse phase) and don't use the Session Scope.

        • 1. Re: how to decide page's scope which has h:dataTable in it?
          mail.micke

          Have a look at the PAGE ScopeType, it is excellent (and something which seems to be incuded in the jsf 2.0 spec).


          As long as you stay on the same page the state of the backing bean will be kept, but when you navigate a way from the page it will be cleaned up.


          Listened to Pete talk about it a while ago and it is a bit more complicated that what I just said but the bottom line is as long as you stay on the same page the state is saved.


          - micke

          • 2. Re: how to decide page's scope which has h:dataTable in it?
            pmuir

            obviously there will be a memery-leak

            How?

            • 3. Re: how to decide page's scope which has h:dataTable in it?
              holan

              Pete Muir wrote on Jul 31, 2008 11:52:


              obviously there will be a memery-leak

              How?

              I use ScopeType.Session in the page which contains h:dataTable.If I navigate to the other page.The page having h:dataTable is still in the memery even when I don't need it.Is this not a memery-leak? If my application has lots of pages with h:dataTable.There is a lot of stateful bean to keep.