On 1/6/06, Garner, Shawn <[EMAIL PROTECTED]> wrote:
>
> Could you elaborate on this?


Which "this" are you referring to?  Laurie's comment about dependency
injection?  I covered that on my reply to the comment (on Wednesday),
reproduced here:

--------------------------------------------------

Good point ... that's even easier.

Assume you have a managed bean named "business" that you want to inject into
the backing bean containing your submit action.  If that bean is called
"myself", you would ensure that it has a public property that corresponds to
the type of your business logic bean:

    public MyBean getBusinessBean() { ... }
    public void setBusinessBean(MyBean bean) { ... }

and you'd configure it in faces-config.xml like this:

  <managed-bean>
    <managed-bean-name>myself</managed-bean-name>
    <managed-bean-class>com.mycompany.MyBackingBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    ...
    <managed-property>
      <property-name>businessBean</property-name>
      <value>#{business}</value>
    </managed-property>
    ...
  </managed-bean>

Then, the business logic bean will get injected for you (created if
necessary the first time) any time your backing bean is created.  The only
restriction is that you can't inject a bean from a shorter scope into a bean
with a longer scope ... but that won't be an issue for something like this,
because your page-oriented backing bean would typically have request scope,
and the business logic bean would have application scope (if it was shared
across all users), or perhaps the "none" scope to get a new instance every
time.

-----------------------------------------------

Craig

Reply via email to