Andrew, thanks for your answer. The bean is created the first time and I know that because I have an EL reference to a property of that bean. What I am trying to do is to get the url query string passed along with the request and print it (for testing). The first time I call the page it succesfully get the url query string , but the second time I call the page it wont execute the constructor and then the property used by the EL wont change to the new url query string.

On Thu, 02 Oct 2008 13:59:34 -0400, Andrew Robinson <[EMAIL PROTECTED]> wrote:

No, the point is that beans are not created until they are used.

So if you have <h:outputText value="#{myBean.someVariable}" />, and then
that component is rendered, the OutputTextRenderer will call getValue() on
the HtmlOutputText component. This causes #{myBean.someVariable} to be
evaluated. When faces sees that myBean is a request scope bean but does not
exist yet, it creates one. Then getSomeVariable() is called on that new
instance.

Therefore, managed beans are only created when they are asked for by the EL resolver. So unless you actually evaluate #{myBean} or a property of myBean,
myBean will never be created. This is for performance. If there is no
request for a java bean, why create one?

So to your original question, you say your constructor is not called, my
question is if you are sure you bean is even being used. The constructor
will only be called when the bean is needed.

-Andrew

On Thu, Oct 2, 2008 at 11:56 AM, Alex Diaz <[EMAIL PROTECTED]> wrote:

Yes I have a reference like that. should I remove it?


On Thu, 02 Oct 2008 12:52:37 -0400, <[EMAIL PROTECTED]>
wrote:

 It just means you have some EL reference in the page like

<t:outputText value="#{myBean.someVariable}" />

In this case "myBean" is being referenced.

-----Original Message-----
From: Alex Diaz [mailto:[EMAIL PROTECTED]
Sent: jeudi 2 octobre 2008 18:28
To: MyFaces Discussion
Subject: Re: managed bean with request scope

I dont know what referred means?

On Thu, 02 Oct 2008 11:31:58 -0400, Andrew Robinson
<[EMAIL PROTECTED]> wrote:

 Is your bean referred to? Beans are created lazily, so if the EL

engine

never resolves that bean, it will not be created.

On Thu, Oct 2, 2008 at 7:47 AM, Alex Diaz <[EMAIL PROTECTED]>

wrote:


 Are the managed beans with request scope destroyed after each request


 to a
page? If so, then why the beans constructor is not being called after
subsequent requests?

Thanks.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/







--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Reply via email to