As suggested by a user time ago in another question, I need to inject a bean in another bean.
So, i do the following :
@ManagedBean
@RequestScoped
public class Articles {
private String selectedMenu;
@ManagedProperty(value="#{user}")
private UserManager user;
@PostConstruct
public void init() {
if(selectedMenu==null || selectedMenu.trim().isEmpty()) {
this.selectedMenu="0";
}
}
// now here i should access to user.methods
// getter and setter
}
In fact, i can't access to UserManager data. I get these error :
BROWSER malformedXML: INVALID_STATE_ERR: Dom Exception 11
SERVER LOG
30-nov-2010 15.36.58 javax.faces.component.UIViewRoot$ViewMap put
AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)
30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean
GRAVE: JSF will be unable to create managed bean articles when it is requested. The following problems where found:
- Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.
30-nov-2010 15.36.59 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
GRAVE: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean articles. The following problems were found:
- Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.
If i comment @ManagedProperty(value="#{user}")
and private UserManager user;
than i don't see any error. So that's the problem. What am I wrong?
Cheers