Search code examples
jakarta-eejava-ee-7

Difference between @Named and @Model


What is the difference between javax.enterprise.inject.Model and javax.inject.Named ? Both are available from JSF EL.


Solution

  • @Model is just a shortcut for a @RequestScoped @Named (in other words @model is a stereotype which incorporates other annotations more about stereotypes here)

    therefore

    @Model
    public class MainBean {
    //...
    

    is equal to

    @Named
    @RequestScoped
    public class MainBean {
    //...