@Named
@RequestScoped
public class
SourceBean {
private String source;
@PostConstruct
public void init(){
source = "SourceBean";
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}
import
javax.faces.annotation.ManagedProperty;
...
@Named
@RequestScoped
public class
TargetBean {
@Inject
@ManagedProperty("#{sourceBean}")
private SourceBean sourceBean;
@Inject
@ManagedProperty("#{sourceBean.source}")
private String source;
public void targetAction(){
System.out.println("Injected bean:
" + sourceBean);
System.out.println("Injected property
(via injected bean): " + sourceBean.getSource());
System.out.println("Injected property:
" + source);
}
}
The complete example is available here.