我有这种情况:
我有一个goToDetail(String item)
在方法loginBean
中选择项目时,这应有助于page2.xhtml。
当我尝试从通过性loginBean
来dettaglioBean
,属性是null
在dettaglioBean
当page2.xhtml被渲染或@PostConstruct
上升。
这里是goToDetail
方法:
public String goToDetail(VStatoavanzamentoriep item) {
FacesContext context = FacesContext.getCurrentInstance();
DettaglioBean bean = (DettaglioBean) context.getApplication().evaluateExpressionGet(context, "#{dettaglioBean}", DettaglioBean.class);
bean.setItem(item);
return Constants.PageID.DettaglioID;
}
并dettaglioBean
声明为managedBean
faces-config.xml中
当我转到page2.xhtml时,item
是null
。
我应该使用依赖项注入包括:
@ManagedProperty("#{dettaglioBean}") //+ setter
private DettaglioBean dettaglioBean;
在loginBean
?
您可以通过将loginBean注入到dettaglioBean中而不是相反的方式来访问loginBean中的值,因为这是您在dettaglioBean中所需的loginBean中的值。
@ManagedProperty("#{loginBean}")
private LoginBean loginBean;
当JSF实现遍及EL时,它将在各种作用域图中搜索Bean对象,并在找到它时将其注入到您的dettaglioBean中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句