Shikha Dhawan
Shikha Dhawan

Reputation: 1424

Scopes in JSF 2

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

Upvotes: 5

Views: 20373

Answers (1)

Matt Handy
Matt Handy

Reputation: 30025

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.

Upvotes: 16

Related Questions