5

I have a CRUD application.. Where in the data is fetched, displayed n edited n stored back to db. Also there is a sequential access between pages & the information entered on the first page is needed on the second page & so forth. What would be the best scope & why ?

When to use which scope? What is the life-cycle of each scope.

Also, I couldn't find any good tutorial on scopes. If you are aware of the same, please guide.

Thanks, Shikha

Shikha Dhawan
  • 1,414
  • 8
  • 27
  • 44
  • possible duplicate of [How to choose the right bean scope?](http://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope) – BalusC Mar 16 '12 at 11:21

1 Answers1

16

There is a detailed explanation of JSF scopes in BalusC's excellent tutorial Communication in JSF 2.0.

As rule of thumb I would recommend to always choose the most narrow scope in order to reduce the state that is saved on the server side. Your application would have a bad scalability if you kept everything in session scope. The view scope is especially useful if you are working with ajax. For non-ajax views the request scope is often sufficient.

Matt Handy
  • 29,855
  • 2
  • 89
  • 112