I am having problems understanding a few scope concepts.
Let's say I have this Bean (used in a xhtml):
@Named
@RequestScoped
public class ConfigController implements Serializable {
@Inject
ConfigModel config; // Bean is @SessionScoped
}
If a ConfigController is created for each http request, what about the injected ConfigModel inside ? Does it keep its values, or is it recreated with the controller ? (I doubt it ?)
What if a ConfigModel is injected in multiple beans with different scopes ?
As I gathered, the scope hierarchy should go from broad to narrow: - Models should be session scoped, since they contain the data - Controllers (and services below) can be request scoped, since they only implement logic.
This is the original problem I am facing: @SessionScoped CDI bean is a different Instance when injected