-1

I have a Spring 3.0 + JSF 2.0 web application with spring managed beans. Currently all the beans are session scoped. In our application we are not using any wizard kind of feature. All the major functionality appears in different tabs.

Recently we analyzed the application code with one of the static code analyzer and it points to possible race-condition issues at many locations in session scoped beans. I understand in multiple tab scenario, using session bean can be problematic. Then I read an article http://blog.primefaces.org/?p=702 which suggest that JSF viewScope can be implemented as spring's custom scope to prevent this kind of situation. When I tried using that for few of my beans, it breaks the corresponding application functionality.

Now I have 2 questions - 1. How much scary the situation can be in future with current usage of spring session bean in terms of race-condition situation with my kind of application? 2. Is there any other way to handle multiple tab issue with session scope beans?

Welcome any suggestions. Thanks

Neeraj
  • 1
  • 2
  • I don't do Spring, but I understood that Spring already supports something like `@Scope("view")` (perhaps since a certain version only, or using some custom code; Googling using "spring jsf view scope" yields a lot of results). It should suit your functional requirement. Then, as to choosing the right bean scope, this is a helpful read: http://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope/7031941#7031941 You should never rely on corner cases to never happen. It's simply *wrong* to use the wrong scope for the purpose. – BalusC Aug 30 '13 at 12:42
  • @user2704708.... I had worked in the past with `JSF 2.0 +spring 3.0` and `@viewscope`. I tried as in this http://stackoverflow.com/questions/13005421/jsf-view-scope-in-spring-3-0/14887965#14887965. Checkout that answer may be i will help to get some idea – SRy Aug 30 '13 at 13:10
  • The approach I use for Spring 3 + JSF 2 is just let a JSF `@ApplicationScoped` bean load the whole Spring context. That bean acts then as an Stateless singleton and is injected in every single `@ViewScoped` bean I use for views. That way every view can locate the service via that bean and access the DAO services. – Aritz Aug 30 '13 at 18:00

1 Answers1

0

Actually view scope implementation in Spring for JSF not really sophisticated. I've created artifact which will solve this problem.

See my github javaplugs/spring-jsf repository.

rumatoest
  • 403
  • 5
  • 9