You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Lisa <ap...@purpleblade.net> on 2007/02/09 07:17:27 UTC

managed-bean - request scope question

As I understand it a managed-bean that is request scope will get instantiated
each time (a request is submitted) and then destroyed (or sent for garbage
collection) after the response.

I put some print statements in the no arg constructor and see that it is
instantiated (and all setters called with Spring injection) the first time
the page is requested, but then when I hit other buttons on the page
(subsequent requests), I do not see the bean re-instantiated (and setters
called) etc.

any ideas?  I have seen some beans that get instantiated on every request,
but the few that I am working with don't.  I have checked my config file and
it is indeed in "request" scope.

It acts like it is in session scope or something.  I should see the no-arg
constructor called each time for a request.

thanks


L
-- 
View this message in context: http://www.nabble.com/managed-bean---request-scope-question-tf3198755.html#a8880992
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: managed-bean - request scope question

Posted by Werner Punz <we...@gmail.com>.
Lisa schrieb:
> As I understand it a managed-bean that is request scope will get instantiated
> each time (a request is submitted) and then destroyed (or sent for garbage
> collection) after the response.
> 
> I put some print statements in the no arg constructor and see that it is
> instantiated (and all setters called with Spring injection) the first time
> the page is requested, but then when I hit other buttons on the page
> (subsequent requests), I do not see the bean re-instantiated (and setters
> called) etc.
> 
> any ideas?  I have seen some beans that get instantiated on every request,
> but the few that I am working with don't.  I have checked my config file and
> it is indeed in "request" scope.
> 
> It acts like it is in session scope or something.  I should see the no-arg
> constructor called each time for a request.
> 
You savestate those beans, right?

If the bean is safestated I am not sure if the constructor is called at
all, because it is just deserialized.
It basically saves the bean and a copy of the bean is placed after the
request back into memory, hence I do not think the constructor of those
beans is called, why it still is there.

Savestate is very similar to a limited scope bigger than request but
smaller than session. (similar to the Rails flash scope in many aspects)