5 Replies Latest reply on Sep 27, 2011 10:06 AM by bitec

    RenderScoped VS ViewScoped

    bitec

      Hi.


      I use CDI ViewScope intensively (the one, offered by Steven Verborgh: http://www.verborgh.be/articles/2010/01/06/porting-the-viewscoped-jsf-annotation-to-cdi/) but in production I face memory problems: sessions grow rapidly and take much memory. In business purpose I have pretty long session timeout (about 7 hours). I tried to diminish the number ov JSF views and logical views in session (


      com.sun.faces.numberOfViewsInSession=5



      and


      com.sun.faces.numberOfLogicalViews=10



      ) but this has not resulted in some prominent success.


      In this case I'm thinking about RenderScope, suggested by Seam faces. Seems these beans are destroyed sooner, than view scoped - as far as written in documentation. Can anyone say something about shortcomings and advantages of renderScope in comparison to viewScope? Are there any hidden obstacles of using this scope?


      Thanks.

        • 1. Re: RenderScoped VS ViewScoped
          bitec

          Unfortunatelly renderScope does not work for me... For some reasons every postback generates the new beans. This code:




                 ConcurrentHashMap<Contextual<?>, Object> map = (ConcurrentHashMap<Contextual<?>, Object>)    getCurrentRenderContext()
                          .get(COMPONENT_MAP_NAME);
          
                  if (map == null) {
                      map = new ConcurrentHashMap<Contextual<?>, Object>();
                      getCurrentRenderContext().put(COMPONENT_MAP_NAME, map);
                  }



          from RenderScopedContext.getComponentInstanceMap() always creates new map on each postback request. That's why all  renderScoped beans are recreated on each ajaxian request.

          • 2. Re: RenderScoped VS ViewScoped
            marcosaps

            Use the same @javax.faces.bean.ViewScoped with Seam Faces. It is working for me.


            Marcos

            • 3. Re: RenderScoped VS ViewScoped
              bitec

              Any thoughts about why render scope didn't work? I tried both Glassfish 3.1 and 3.11 and Seam Faces 3.02, but the context is still lost on postback.


              Thanks.

              • 4. Re: RenderScoped VS ViewScoped
                marcosaps

                Anton Lisovenko wrote on Sep 27, 2011 04:17:


                Any thoughts about why render scope didn't work? I tried both Glassfish 3.1 and 3.11 and Seam Faces 3.02, but the context is still lost on postback.

                Thanks.


                No. I didn't even tried the render scope and I'm not thinking of doing this. I went directly to the @ViewScoped, as I was translating from JSF to CDI.


                Marcos

                • 5. Re: RenderScoped VS ViewScoped
                  bitec

                  Marcos, I'm asking those, who tried, I understood, that you don't use render scope.


                  So, is there anyone with the same problems with it? Maybe Seam Faces contributors could advise smth.


                  Thanks.