Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 48916 invoked from network); 26 Jul 2007 14:32:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jul 2007 14:32:59 -0000 Received: (qmail 96459 invoked by uid 500); 26 Jul 2007 14:32:55 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 96429 invoked by uid 500); 26 Jul 2007 14:32:55 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 96413 invoked by uid 99); 26 Jul 2007 14:32:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2007 07:32:54 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of simon.lessard.3@gmail.com designates 64.233.162.231 as permitted sender) Received: from [64.233.162.231] (HELO nz-out-0506.google.com) (64.233.162.231) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2007 07:32:53 -0700 Received: by nz-out-0506.google.com with SMTP id r28so454636nza for ; Thu, 26 Jul 2007 07:32:32 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=YXFEjuTlceeix3aJJf6YYVw6YVh2uHG/lT7bVUY9258axcr3gkzYnym3MJdZBrhJp/iWfANHCWziC6k0GPFeRhjBgig+ArhplIOR0cxvtVqgngPvMAfbbTKI70GFbVj6dTuSCzUuYCedMuOGRjLEbnRZcJuA7XVWAytqDsoL8Us= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=dEZarTUKKE9tPRcnVq73yyapm/JjfVy7bIu4Hhia2Uv+uIsr4ZJiVLGV48sX/9O1cn7tike1q7/EIsyNpZUYUshOqoKUzThs/aIaRhzhVdZnOQ3xwgOYoFGL7puNcZfUrOk6mBq20oKOWwNZJ5EoEpkWiLXl16gItX8WHrbtZTA= Received: by 10.114.60.19 with SMTP id i19mr1770135waa.1185460351297; Thu, 26 Jul 2007 07:32:31 -0700 (PDT) Received: by 10.114.152.7 with HTTP; Thu, 26 Jul 2007 07:32:30 -0700 (PDT) Message-ID: <254acf980707260732l198ac484l5094802406db9a4b@mail.gmail.com> Date: Thu, 26 Jul 2007 10:32:31 -0400 From: "Simon Lessard" To: "MyFaces Discussion" Subject: Re: Instantiate a backing bean from other In-Reply-To: <926786cb0707260726l1cf684c7u29554cc26e9f1130@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_146731_20638377.1185460351006" References: <281795.31448.qm@web25503.mail.ukl.yahoo.com> <926786cb0707260726l1cf684c7u29554cc26e9f1130@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_146731_20638377.1185460351006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, It depends on the use case: 1. If the bean needing the information for the other is request scoped, the info is always needed and is unlikely to change over the request lifecycle, using a managed-property to inject the value directly is most likely the best way. 2. If the required value change over the request lifecycle or the bean is more persistent than request and the requested value change over time, then use a managed-property to inject the other bean itself. 3. Use the VariableResolver, it's more efficient than ValueBinding. Regards, ~ Simon On 7/26/07, Fabio Stracuzzi wrote: > > FacesContext currentFacesContextInstance =3D FacesContext.getCurrentInsta= nce > (); > You can test this code: > > ValueBinding valueBinding =3D currentFacesContextInstance.getApplication(= ).createValueBinding("#{" > + managedBeanName + "}"); > > return valueBinding.getValue(currentFacesContextInstance); > > If Your managedBean has Session scope (or Application Scope), the returne= d > bean is same istance, otherwise the method will create a new instance. > > Best regarde > Fabio > > > 2007/7/26, Angel Miralles Arevalo : > > > > It isn't necesary managed bean in session scope, for example: > > > > > > AuthorizationMembersGroupBean menGroup =3D (AuthorizationMembersGroupBe= an) > > getApplication().createValueBinding( > > "#{requestScope.authorizationMembersGroupBean}" > > ).getValue(facesContext); > > > > > > > > getApplication().createValueBinding( > > "#{requestScope.authorizationMembersGroupBean}").setValue(facesContext,= menGroup); > > > > > > > > What you need to know is than you obtain the managed bean, alter it and > > you have to update it in facesContext...the second line... > > > > ----- Mensaje original ---- > > De: daniel ccss < danielccss2@gmail.com> > > Para: MyFaces Discussion > > Enviado: jueves, 26 de julio, 2007 15:56:25 > > Asunto: Instantiate a backing bean from other > > > > Is there a way to use a BackingBean from another BackingBean o another > > class, the scope of the backing bean is session. > > > > For example I need to call the get method of a variable of a BackingBea= n > > on another Backing Bean > > > > It is possible or I=B4m to crazy? > > > > > > > > ------------------------------ > > > > S=E9 un Mejor Amante del Cine > > =BFQuieres saber c=F3mo? =A1Deja que otras personas te ayuden! > > > > . > > > > > > -- > Ciao ciao > Fabio ------=_Part_146731_20638377.1185460351006 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello,

It depends on the use case:

1. If the bean needing the= information for the other is request scoped, the info is always needed and= is unlikely to change over the request lifecycle, using a managed-property= to inject the value directly is most likely the best way.
2. If the required value change over the request lifecycle or the bean = is more persistent than request and the requested value change over time, t= hen use a managed-property to inject the other bean itself.
3. Use the V= ariableResolver, it's more efficient than ValueBinding.


Regards,

~ Simon

On 7/26/07, Fabio Stracuzzi <fabiostracuzzi@gmail.com> wrote= :
FacesContext= currentFacesContextInstance =3D FacesContext.getCurrentInstance();
You = can test this code:
 
ValueBinding valueBinding =3D currentFacesContextInstance.getApplicati= on().createValueBinding("#{" + managedBeanName + "}");&= nbsp;

return valueBinding.getValue(currentFacesContextInstance);
=  
If Your managedBean has Session scope (or Application Scope), the retu= rned bean is same istance, otherwise the method will create a new instance.=
 
Best regarde
Fabio
 
 
2007/7/26, Angel Miralles Arevalo <anmiralles@yahoo.es>:
It isn't necesary managed bean in session scope, for example:
 

AuthorizationMembersGroupBean menGroup =3D (Authorization= MembersGroupBean) getApplication().createValueBinding(

"#{requestScope.authorizationMembersGroupBean= }" ).getValue(facesContext);=20

 

getApplication().createValueBinding(

"#{requestScope.authorizationMembersGroupBean= }").setValue(facesContext,menGroup);=20


What you need to know is than you obtain the managed bean= , alter it and you have to update it in facesContext...the second line... 
----- Mensaje original ----
De: daniel ccss < danielccss2@gmail.com>
Para: MyFaces Discussion <users@myfaces.apache.org>
Enviado:= jueves, 26 de julio, 2007 15:56:25
Asunto: Instantiate a backing bean from other

Is there a way to use a BackingBean from another BackingBean o another= class, the scope of the backing bean is session.
 
For example I need to call the get method of a variable of a BackingBe= an on another Backing Bean
 
It is possible or I=B4m to crazy?

 



S=E9 un Mejor Amante del Cine
=BF= Quieres saber c=F3mo? =A1Deja que otras personas te ayuden! .



--
Ciao ciao
Fabio=20

------=_Part_146731_20638377.1185460351006--