2012-10-05 50 views
0

我想在我的代码中实现样本气泡图作为测试,然后再与相关数据库连接。以下是我的chartBean.java代码:Primefaces 4气泡图错误

package jsf; 


import java.io.Serializable; 
import javax.enterprise.context.Dependent; 
import javax.faces.bean.ManagedBean; 
import org.primefaces.model.chart.BubbleChartModel; 
import org.primefaces.model.chart.BubbleChartSeries; 

/** 
* 
* @author AOL 
*/ 
@ManagedBean(name = "chartBean") 
@Dependent 

public class ChartBean implements Serializable { 

    private BubbleChartModel bubbleModel; 

    public ChartBean() { 
     createBubbleModel(); 
    } 

    private void createBubbleModel() { 
     bubbleModel = new BubbleChartModel(); 

     bubbleModel.add(new BubbleChartSeries("Acura", 70, 183,55)); 
     bubbleModel.add(new BubbleChartSeries("Alfa Romeo", 45, 92, 36)); 
     bubbleModel.add(new BubbleChartSeries("AM General", 24, 104, 40)); 
     bubbleModel.add(new BubbleChartSeries("Bugatti", 50, 123, 60)); 
     bubbleModel.add(new BubbleChartSeries("BMW", 15, 89, 25)); 
     bubbleModel.add(new BubbleChartSeries("Audi", 40, 180, 80)); 
     bubbleModel.add(new BubbleChartSeries("Aston Martin", 70, 70, 48)); 
    } 
} 

然后我有一些标准的数据库的东西,做工精细,让我做平常CRUD的东西。

这是包含在网页的代码,试图创建气泡图:

<h:form> 
    <p:bubbleChart id="sample" value="#{chartBean.bubbleModel}" xaxisLabel="Price" yaxisLabel="Labels" 
       title="Sample Bubble Chart" style="width:400px;height:300px" /> 
</h:form> 

当我尝试没有代码,它工作正常访问的页面,但是,当我在这行添加它返回以下错误:

/template.xhtml @45,84 value="#{chartBean.bubbleModel}": The class 'jsf.ChartBean' does not have the property 'bubbleModel'.

回答

3

您必须实现一个返回字段“bubbleModel”的方法。 public BubbleChartModel getBubbleModel(){ return bubbleModel; }

+0

啊哈,当然。谢谢 - 当时,我是一个完全新手。我想我现在已经知道了,但是那么一件小事滑过了我。 – AodhanOL