Bean properties are shared across different sessions

前端 未结 1 989
孤独总比滥情好
孤独总比滥情好 2020-12-20 08:23

I am using JSF Mojarra 2.1.13, PrimeFaces 3.5 and Spring 3.2.3 for my application. For DI I am using Spring approach (not CDI). I am following the tutorial on PrimeFaces dem

1条回答
  •  独厮守ぢ
    2020-12-20 08:54

    Not really sure why you configured the @ManagedBean as a @Component to begin with. This problem is because Spring handles a single instance of @Component across your application (or at least that's how it looks from your explanation). Remove it and use @ViewScoped in your managed bean to make this work as expected. Note that if you use Spring to manage your JSF managed beans, then you have to add this configuration in your faces-config.xml (from mkyong tutorial):

    
        
            org.springframework.web.jsf.el.SpringBeanFacesELResolver
        
    
    

    But doing this you will loss the power of @ViewScoped managed beans. To solve this error, you have to implement the @ViewScoped in Spring. There are plenty examples on the net about this, and looks that the most popular is from Cagatay's

    More info about JSF managed bean scopes: Communication in JSF 2: Managed bean scopes

    0 讨论(0)
提交回复
热议问题