Question

I'm building a web application using jsf2. I use a @ManagedBean with a @SessionScope. In it I store the username etc in a User object. Let's say I want to create an article, for that I have another @ManagedBean @RequestScope that has a createArticle() method, but it needs to set the article author. Should I inject the user session bean through cdi to get the user user object, is it ok to inject managedbeans into other managed beans? May be is there any other approach to would be better?

Was it helpful?

Solution

The whole point of Dependency Injection is to inject managed beans into other managed beans. So yes, your approach is the way to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top