I try to get instance of managed bean in another managed bean thanks to this BalusC post : here
With findBean
method, it's great, I retrieve my bean but with ManagedProperty
I can not get my bean.
My bean to inject is this one :
@ManagedBean(name="locale")
@SessionScoped
public class LocaleBean {
private String locale;
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(locale));
this.locale = locale;
}
}
So when I call LocaleBean locale = findBean("locale");
in my login
bean it's work but :
@ManagedProperty("#{locale}") // OR localeBean, LocaleBean...
private LocaleBean locale;
doesn't work...
com.sun.faces.mgbean.ManagedBeanCreationException: Impossible de créer le bean géré «login». Les problèmes suivants ont été détectés : - La propriété «locale» du bean géré «login» n’existe pas.
Why please ?