正如用户前段时间在另一个问题中所建议的那样,我需要在另一个 bean 中注入一个 bean。
所以,我执行以下操作:
@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
}
事实上,我无法访问 UserManager 数据。我收到这些错误:
浏览器 malformedXML: INVALID_STATE_ERR: Dom Exception 11
服务器日志
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.
如果我发表评论@ManagedProperty(value="#{user}")
并且private UserManager user;
我没有看到任何错误。所以这就是问题所在。我错了什么?
干杯