myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: managed bean with request scope
Date Thu, 02 Oct 2008 17:59:34 GMT
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 <alexware69@gmail.com> wrote:

> Yes I have a reference like that. should I remove it?
>
>
> On Thu, 02 Oct 2008 12:52:37 -0400, <Matt.Rossner-prest@sanofi-aventis.com>
> 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:alexware69@gmail.com]
>> 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
>> <andrew.rw.robinson@gmail.com> 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 <alexware69@gmail.com>
>>>
>> 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/
>

Mime
View raw message