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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top