3 Replies Latest reply on Jun 21, 2012 10:13 AM by Lukasz Lenart

    RenderScoped and RequestScoped what is the difference?

    Enes Tahan Newbie

      Hiya all,
      i want to understand the
      difference between Request scope and render scope? i checked the ref. manuel, and i tired on a few examples i didnt get it well.


      first of all request scope :

      • Request: Objects with this scope are visible from the start of the request until the end
      of the request. Request scope starts at the beginning of a request and ends when the
      response has been sent to the client. If the request is forwarded, the objects are visible
      in the forwarded page, because that page is still part of the same request/response
      cycle.

      and Seam Faces render scope definition:

      • Beans placed in the @RenderScoped context are effectively scoped to, and live through but not after, "the next Render Response phase".
      @RenderScoped beans are destroyed when the next JSF RENDER_RESPONSE phase ends.

      when i tried both scopes they were working the same way.

      when i checked the current phase id in  preDestroy interceptor i got RenderResponse from both scoped bean.
      i navigated from request scoped and render scoped page to another one they destroyed after Render Response phase.

      so what is the difference betweem these two scopes that i couldnt get from the reference manuel and my trival examples ?

        • 1. Re: RenderScoped and RequestScoped what is the difference?
          Enes Tahan Newbie
          Sorry this was my first post on seam forum i didnt notice the formatting stuff.

          hiya all,
          i want to understand the difference between Request scope and render scope? I checked the ref. manuel, and i tired on a few examples i didnt get it well.

          first of all request scope :

          • Request: Objects with this scope are visible from the start of the request until the end
          of the request. Request scope starts at the beginning of a request and ends when the
          response has been sent to the client. If the request is forwarded, the objects are visible
          in the forwarded page, because that page is still part of the same request/response
          cycle.

          and Seam Faces render scope definition:

          • Beans placed in the @RenderScoped context are effectively scoped to, and live through but not after, the next Render Response phase.RenderScoped beans are destroyed when the next JSF RENDER_RESPONSE phase ends.

          when i tried both scopes they were working the same way.

          when i checked the current phase id in  preDestroy interceptor i got RenderResponse from both scoped bean.
          i navigated from request scoped and render scoped page to another one they destroyed after Render Response phase.

          so what is the difference betweem these two scopes that i couldnt get from the reference manuel and my trival examples?
          • 2. Re: RenderScoped and RequestScoped what is the difference?
            Brian Leathem Master

            The request scope is bounded by a single iteration of the JSF lifecycle.  The render scope will survive until the end of the Render Response phase of the next iteration of the JSF lifecycle.  At least, that's the expected behaviour. 


            If you find that it is not behaving this way for you, please file a jira issue with details of your environment, and if at all possible an example demonstrating the behaviour you observe.

            • 3. Re: RenderScoped and RequestScoped what is the difference?
              Lukasz Lenart Newbie

              I was trying to use @RenderScoped instead @ConversationScoped but it looks like the backing bean is created on each request - even Ajax. I thought that the @RenderScoped should have wider scope than @ViewScoped (the bean is created one per view, even if there are subsequent ajax calls) and the bean should survive between two requests. Did I miss something ?