CDI defines one further standard stereotype, @Model, which is expected to be used frequently in web applications:
@Named
@RequestScoped
@Stereotype
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface Model {}
Instead of using JSF managed beans, just annotate a bean @Model, and use it directly in your JSF view!
So why can't we just use @Named instead? Like in Seam, there was no @Model, if an entity class had a @Name it could be referenced directly in a JSF view.
Also, how was it decided that @Model is @RequestScoped? Why not @ConversationScoped? I guess we must create a new stereotype for that...
And what about hybrid stereotypes?:
@Named
@RequestScoped
@ConversationScoped
@Stereotype
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface ModelFlexible {}
so that we must specify via an attribute if we want it to be request or conversation scoped...
@ModelFlexible(mode=ModeType.CONVERSATION)
public class MyModel {...}
but then this perhaps is not type-safe??
or maybe create two new stereotypes:
@ModelRequestScoped and @ModelConversationScoped
or remove the scoping meta-annotation from the annotation and then simply do:
@Named
@Stereotype
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface ModelNew {}
@ModelNew @ConversationScoped
public class MyFoo {...}