Nov 7, 2018

Scopes of managed beans in JSF

Do not try to point a managed bean to another managed bean with a shorter life span, because it might be impossible to recover that scope’s resources when it goes away. A session-scoped bean, for example, cannot point to a request-scoped bean. For example, none-scoped bean have no effective life span managed by the framework, so they can point only to other none-scoped beans. Also be sure not to allow cyclical references between beans.
Allowable Connections Between Scoped Beans
An Object of This ScopeMay Point to an Object of This Scope
nonenone
applicationnoneapplication
sessionnoneapplicationsession
viewnoneapplicationsessionview
requestnoneapplicationsessionrequestview

The @Model annotation does 2 things:
  1. it makes the bean request-scoped (instead of dependent, the default
  2. it gives the bean an EL name 
Creating a request-scoped and named bean is typically accomplished by apply the annotations @RequestScoped and @Named to the class, respectively. Since the combination of these annotations is so common in web applications, the built-in stereotype annotation @Model is provided by CDI as a shorthand.