2 Replies Latest reply on Mar 7, 2011 2:30 PM by richfacesfan

    ViewScoped or Request Scoped

    richfacesfan

      Hi wich is this best option or this is depend of case?????

       

      ViewScoped

      or

      RequestScoped

      for the backing of page that contain :

                bindings,

                crud actions.

       

      please help¿¿¿

        • 1. ViewScoped or Request Scoped
          boy18nj

          RequestScoped:

          The request scope is short-lived. It starts when an HTTP request is submitted

          and ends after the response is sent back to the client. If you place a managed

          bean into request scope, a new instance is created with each request. It is worth

          considering request scope if you are concerned about the cost of session scope

          storage.

           

          Example- Data for error and status messages can often be placed in request scope.

           

          ViewScoped:

          If you have complex data, such as the contents of a table, then request scope

          may not be appropriate since you would need to regenerate the data with

          every request.

           

          A bean in view scope persists while the same

          JSF page is redisplayed.

          As soon as the user navigates to a different page, the bean goes out of scope.

          If you have a page that keeps getting redisplayed, then you can put the beans

          that hold the data for this page into view scope, thereby reducing the size of the

          session scope.

           

          Example- This is particularly useful for Ajax applications.

           

           

          For the backing beans that contain bindings, I would recommend go with ConversationScoped or if it is single page than RequestScoped.

          For crud actions,  if it is an ajax action go with View Scope otherwise Request Scope.

          • 2. ViewScoped or Request Scoped
            richfacesfan

            thanks , for the explantion

            regardss!!!!

            Richfacesfan