• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Backing Bean Scope (Best Practices?)

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Venkat-
Thanks for the response. I will ask around in the Sun forums as you suggested.
~Zack
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic