• Post Reply Bookmark Topic Watch Topic
  • New Topic

Backing Bean Scope (Best Practices?)

 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am curious about the best way to decide what scope a backing bean should exist in.

When I first started with JSF, I just put all my beans into session scope. Then I could easily access them all the time -- even on ajax calls -- and their data would persist across requests.

However, I have seen many people suggest that storing beans in session scope should not be done lightly due to performance issues, etc.

My question is: when should I use request scope, and when should I use session scope?

Right now, my solution is to have a single backing bean in session scope which just holds data I want to persist across requests, such as EJBs. Then I have my JSF pages only directly reference request scope beans, which provide delegate methods to the session scoped EJB fields.

Does this sound like a good solution, or are there better patterns out there?

Thanks in advance
~Zack
 
Venkat Sadasivam
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a challenging question for JSF design. You should post in Sun forum.

To me what you are doing is right. But you might find difficulty in using request scope for datatable pages.
 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venkat-
Thanks for the response. I will ask around in the Sun forums as you suggested.
~Zack
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!