Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem accessing data from another managedBean

 
doinigly jaquel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to access data from another managedBean,
I tested this from documentation :

but I have a problem with "context"
do you have any idea
thank you
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18154
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#1 rule for JSF. The more complex your solution, the more likely it's wrong.

One of the core design principles of JSF is Inversion of Control. In IoC, things don't "go out and get" other things (that's what Service Locators are for). Instead, they sit there all fat and happy and get them delivered via Injection.

JSF does this via Managed Properties. In JSF1, you defined Managed Properties in the faces-config.xml as part of your Managed Bean definition. That still works in JSF2, but you also can use the "@ManagedProperty" annotation. Like so:



This will cause JSF to invoke your setUserId() property access method to set the userId property without the need for gnarly JSF-specific code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic