So I saw this post: JSF is a bean session shared by browsers on different machines
But that was a question two years ago, so I donβt know if there have been any updates in the JSF world since then, and I also have some more specific cases for which I would like clarification. Basically, I would like to know how static scope variables are processed in beans with different scopes. For instance:
@ManagedBean @ApplicationScoped public class ApplicationBean{ static private int someStaticInt=0; ... }
Since this bean is the application area, I would fully expect that someStaticInt will be used by all users of the application, that is, user A sets the value to 3, all users will continue to see this value as 3. Correct me if I'm Wrong.
But what about this scenario:
@ManagedBean @ViewScoped public class ViewScopeBean{ static private int staticInt = 0; private SomePOJO myClass; ... public void someAction(){ SomePOJO.memberStaticInt++; ... } } ... public SomePOJO{ static private int memberStaticInt = 0; ... }
Now this bean is ViewScoped, so there is a separate instance for each application user. But what about this static int? If I increase this value, it will only be in the MY instance of the Bean, or it will be increased for all users. Also, what about the myClass member object? It is not declared static in a Bean, but it has a static member. If I run someAction, will memberStaticInt increase for all users or just for the user using this Bean instance?
Finally, I would be interested to know if any and all such logic in the above cases applies to RequestScoped beans.
source share