Thanks.

 


From: Craig McClanahan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 21, 2006 8:59 PM
To: MyFaces Discussion
Subject: Re: managed properties

 

On 6/21/06, Rick <[EMAIL PROTECTED]> wrote:

<managed-bean>
  <managed-bean-name>businessDelegate</managed-bean-name>
  <managed-bean-class>com.delegates.BusinessDelegate</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
  <managed-bean-name>manageMyBean</managed-bean-name>
  <managed-bean-class>com.beans.ManageMyBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
  <managed-property>
           <property-name>businessDelegate</property-name>
           <value>#{requestScope.businessDelegate}</value>
  </managed-property>
</managed-bean>

The above injects businessDelegate into manageMyBean. It also creates a new
instance if it is needed.


Actually, you're working too hard.  Just use:

    <value>#{businessDelegate}</value>

 

JSF IoC container is not that powerful, I prefer to use Spring and then use
the Spring delegating variable resolver.


You could also write your own JSF variable resolver and then manage the
businessDelegate w/o putting it into scope.


You can accomplish that with standard managed beans my setting the <managed-bean-scope> on the "businessDelegate" bean to be "none".  This is like the create-every-time mode of Spring ... you always get a new instance each time the _expression_ is evaluated, and it is never placed into any scope.


Craig

 

Reply via email to