Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scopes in JSF 2

Tags:

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

like image 753
Shikha Dhawan Avatar asked Mar 16 '12 07:03

Shikha Dhawan


1 Answers

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.

like image 62
Matt Handy Avatar answered Oct 11 '22 14:10

Matt Handy