• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to remove managedBean from Menu In JSF 2.0

 
Sachin Yewale
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working on JSF 2.0 Application.I have created a Menu using rich:dropDownMenu. And for some pages i put managedBean in session scope . but when i click on the the one menu item and then after some time other and again come back to prev menu link it keeps its state. i know i need to remove managedBean from session for this . but i dont understand where to put that code.
My menu code is:


Please help me.
Thanks in advanced.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18281
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't mix JSF and JSTL. It generally does not work very well. And, in any case, the RichFaces menu doesn't need looping of any kind since it works with menu item collections models.

Removing a session-scope managed bean in JSF can be a bit of a problem since JSF has no direct support for that. It's usually easier and cleaner to keep the bean and wipe it clean. A common construct I employ is this:



Since I made init() a public method, I can inject this bean into any beans that will navigate to it and have them invoke init() as part of the navigation action.

An alternative that would probably work for the menus is to use View scope instead of session scope.
 
Sachin Yewale
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim Holloway,
I have view scope to solve my problem.Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic