• Post Reply Bookmark Topic Watch Topic
  • New Topic

Forcing managed bean into session scope

 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all-
I have a session scoped backing bean which is never actually referenced in the view. It is simply used to store EJBs, which can be retrieved by my request scoped beans (which are referenced in my .xhtml files).

However, how can I actually get this session bean into the FacesContext's session scope map? Since it's never actually used on the page, it's never loaded into session.

I realize I could put a dummy variable into the session scope bean and tie it to a hidden field in the view. However, that seems really hacky...any suggestions?

Thanks in advance,
~Zack
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's not really a backing bean if there's no view that it backs - it's just a managed bean.

On the other hand, it sounds like this is a service provider for the request-scoped beans. Specifically as a dispenser for EJBs, though I'd consider pushing the EJBs back a level and letting it provide business logic using the EJBs it's keeping.

Anyway, from that point of view, it seems reasonable that you'd want to inject it into the request backing beans, so not hackey.

If that doesn't suit, remember that there's nothing magic about session-scoped beans managed by the JSF framework compared with session-scoped beans created the old-fashioned manual way. The only difference is that JSF takes over the job of getting them instantiated.
 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the informative reply, Tim! How would I instantiate the session bean the old fashioned way? I am relatively new to JSF, and haven't instantiated them manually before.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!