1

I have a managed bean:

@ManagedBean
@ViewScoped
public class BeanA implements Serializable {
    private TreeNode tree;

... }

and I want to inject it into

@ManagedBean
@ViewScoped
public class BeanB extends Serializable {

   @ManagedProperty(value="#{beanA}")
   private BeanA injectedBean;

... getters and setters for injectedBean
}

but nothing happens when I try to reference properties of BeanA through BeanB on a page. Specifically, I am attempting top reuse functionality of BeanA (the data model for a primefaces tree) on a page that is backed by BeanB. No errors/stack traces result either. No tree is output on the screen but the tree is output on a page that makes direct use of BeanA.

Adam
  • 4,590
  • 10
  • 51
  • 84
  • Seems to be similar problem as [this question](http://stackoverflow.com/questions/12513374/injected-session-scoped-bean-in-view-scoped-bean-duplicating). never seemed to be solved – blo0p3r Oct 02 '12 at 20:19

1 Answers1

0

Put the annotation on a setter for Bean A rather than the member:

@ManagedProperty
public void setInjectedBean(BeanA beanA) {
   this.beanA = beanA;
}

Alternatively, use @Inject instead of @ManagedProperty

8bitjunkie
  • 12,793
  • 9
  • 57
  • 70