File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session values of a Backing Bean in JSF

 
Pradeep Chavan
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 managed beans in session scope. In one managed bean, i get a list of drop down values and display it on the screen. In another UI, i add values to the drop down list. When i am in the same session, when i add values to the drop down, the values do not reflect in the drop down on UI. The old session retains even though the values are inserted in the database. Any inputs on how to fetch the latest values always in the drop down list will be appreciated.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make it a request scoped bean. Or manually access the bean in session scope and update the data. Or introduce the observer pattern so that it can get notified when new values are added then let it reload the data.
 
Pradeep Chavan
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply. I need the bean in the session scope.
Can you post some sample code for reference ?
thanks in advance.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can access session scoped beans by ExternalContext#getSessionMap() (which is actually backed by HttpSession attributes). The managed bean name is the map key.
 
Pradeep Chavan
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method to fetch the drop down list values in the managed bean.
So should I fetch the complete bean using the getSessionmap().get() ?
how can i get only the drop down list and upadet the values as you mentioned.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is obtaining a reference to a managed bean an issue? Your concern doesn't make much sense. If you don't want to access it by the sessionmap, you can also declare it as a managed property of the other bean.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic