我尝试将托管 Bean 注入另一个 bean,但失败了。这是第一个 bean:
@ManagedBean(name = "sucBean")
@SessionScoped
public class SucBean implements Serializable {
private static final long serialVersionUID = 1L;
private MapModel advancedModel;
private MapModel advancedModel2;
private Marker marker;
private Suc suc;
private List<Suc> sucDefteri;
private List<Suc> searchResult;
private Suc[] selectedSuc;
private SucService sucService;
private String aramaKriteri;
private String arananKelime;
private SucDataModel sucModel;
// other getters/setters methods
当我运行 Web 应用程序时,我得到了
Caused by: java.lang.NullPointerException
at org.primefaces.component.chart.CartesianChart.getCategories(CartesianChart.java:32)
at org.primefaces.component.chart.bar.BarChartRenderer.encodeData(BarChartRenderer.java:121)
at org.primefaces.component.chart.bar.BarChartRenderer.encodeScript(BarChartRenderer.java:51)
at org.primefaces.component.chart.bar.BarChartRenderer.encodeEnd(BarChartRenderer.java:36)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
第二个bean如下:
@ManagedBean(name="chartBean")
@SessionScoped
public class ChartBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private CartesianChartModel categoryModel;
@ManagedProperty("#{sucBean}")
private SucBean sucBean;
private int[] sucSayilari=new int[9];
public ChartBean()
{
createCategoryModel();
}