On 6/25/06, Dhananjay Prasanna <[EMAIL PROTECTED]> wrote:
You'll get exception, because this is not a legal usage pattern :-). It is legal to inject a longer-lived object into a shorter-lived object, but not the other way around.
I choose scope for a managed bean just like as for any other bean in a Java based webapp ... if the information is specific to a user but longer lived than a single request, I use session scope. Otherwise, I generally use request scope to avoid multiple instantiations of the same bean.
Spring 1.x didn't support "request" or "session" scope directly ... I'm glad to see they are adding a way to do that in 2.x.
Craig
Good to know. Btw what are the semantics of using mixed-scope managed properties inside each other?
Example:
Backing bean A has request scope
Backing bean B has application scope but contains a managed reference to A.
What am I obtaining when retrieving B.a?
You'll get exception, because this is not a legal usage pattern :-). It is legal to inject a longer-lived object into a shorter-lived object, but not the other way around.
Futhermore, in spring, you either have singletons or "created-every-time", is it a best practise to emulate this? (i.e. all managed properties should either be scope none or scope equal to encapsulating bean)
I choose scope for a managed bean just like as for any other bean in a Java based webapp ... if the information is specific to a user but longer lived than a single request, I use session scope. Otherwise, I generally use request scope to avoid multiple instantiations of the same bean.
Spring 1.x didn't support "request" or "session" scope directly ... I'm glad to see they are adding a way to do that in 2.x.
Dhanji.
Craig