Hello, I want to have a managed bean that is basically one per session.
I have it set up so that singleton="false", and so that the jsf scope is "session". But I have two other beans that have it as a dependency - so when everything starts up, I get two separate instances of the bean.
Is it possible to specify one per session? Or am I hosed?
Thanks,
Dave
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The non-singleton obviously is a spring managed bean. Are the others as well? If so, you might want to reconsider your application design since scopes only apply to JSF and spring beans shouldn't and can't access JSF managed beans. Usually, JSF beans are used for the frontend (needing session scope support) whereas spring beans are used for general application centric processes and tasks, services and such.
A spring bean accessing another spring bean doesn't access it via the scoped JSF bean and thus gets a new instance each time it requests the bean since it is not a singleton.
HTH,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I want to have a managed bean that is basically one per session.
I have it set up so that singleton="false", and so that the jsf scope is "session". But I have two other beans that have it as a dependency - so when everything starts up, I get two separate instances of the bean.
Is it possible to specify one per session? Or am I hosed?
Thanks,
Dave
I'm a novice at this, but does it work correctly if your two other beans also have a scope of "session"?
Nope, doesn't work... they are still initializing twice.
-Dave
The non-singleton obviously is a spring managed bean. Are the others as well? If so, you might want to reconsider your application design since scopes only apply to JSF and spring beans shouldn't and can't access JSF managed beans. Usually, JSF beans are used for the frontend (needing session scope support) whereas spring beans are used for general application centric processes and tasks, services and such.
A spring bean accessing another spring bean doesn't access it via the scoped JSF bean and thus gets a new instance each time it requests the bean since it is not a singleton.
HTH,
Thomas