java - How to inject entire managed bean via @ManagedProperty annotation? -


i'm trying inject entire jsf managed bean managed bean means of @managedproperty annotation (very similar possible inject @managedbean @managedproperty @webservlet?, i'm injecting bean, not servlet). i'm doing:

@managedbean public class foo {   @managedproperty(value = "#{bar}")   private bar bar; }  @managedbean public class bar { } 

doesn't work (jsf 2.0/mojarra 2.0.3):

severe: jsf unable create managed bean foo when  requested.  following problems found: - property bar managed bean foo not exist. check    appropriate getter and/or setter methods exist. 

is possible @ or need injection programmatically via facescontext?

you need add setters , getters

@managedbean public class foo {   @managedproperty(value = "#{bar}")   private bar bar;   //add setters , getters bar   public bar getbar(){       return this.bar;   }   public void setbar(bar bar){       this.bar = bar;;   } } 

when facescontext resolve , inject dependencies use setters injection appropriate setters/getters should there.otherwise won't find property


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -