我的要求是以图形格式显示数据库中的表,我使用斐济来实现这一点。在这样做的时候,我遇到了异常,我的jsp页面如下所示。
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:fiji="http://exadel.com/fiji">
<fiji:columnChart id="columnChartOne" value="#{GraphBean.monthMap}" title="One-series Column Chart" barCaption="none"
barColors="#{GraphBean.colors}" captionX="Months" captionY="Amount" toolTipValue="{y} {name} are sold in {x}"
subtitle="Hardware sales per month" width="400" height="400">
<fiji:chartData type="name" value="#{GraphBean.names}" />
</fiji:columnChart>
</ui:composition>我的bean如下:
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Random;
public class GraphBean {
private Integer data;
private Map<String, Integer> monthMap = new LinkedHashMap<String,Integer>();
private ArrayList<String> names = new ArrayList<String>();
private ArrayList<String> colors = new ArrayList<String>();
Random rnd = new Random(new Date().getTime());
public GraphBean() {
super();
generateData();
}
private void generateData() {
monthMap.put("January", getData());
monthMap.put("February", getData());
monthMap.put("March", getData());
}
public Map<String, Integer> getMonthMap() {
return monthMap;
}
public ArrayList<String> getNames(){
names.add("Motherboards");
return names;
}
public ArrayList<String> getColors(){
colors.add("#5db2c2");
return colors;
}
public Integer getData() {
data = rnd.nextInt(50);
return data;
}
}我已经在faces-config.xml中为bean创建了条目。
发布于 2010-08-01 19:38:50
在JSF中,您可以使用facelet或JSP (尽管不推荐)呈现页面,据我所知,您正在尝试加载JSP页面,同时添加一个facelet标记:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:fiji="http://exadel.com/fiji">
...
</ui:composition>。如果您想使用带有facelet的页面,您可以下载一个使用facelet here的示例。如您所见,页面的名称后缀是.xhtml,而不是.jsp。
如果你想使用JSP,你的页面必须是:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://exadel.com/fiji" prefix="fiji" %>
<html>
<head>
<title>enter your name page</title>
</head>
<body>
<f:view>
<fiji:columnChart id="columnChartOne" value="#{GraphBean.monthMap}" title="One-series Column Chart" barCaption="none"
barColors="#{GraphBean.colors}" captionX="Months" captionY="Amount" toolTipValue="{y} {name} are sold in {x}"
subtitle="Hardware sales per month" width="400" height="400">
<fiji:chartData type="name" value="#{GraphBean.names}" />
</fiji:columnChart>
</f:view>
</body>
</html>再说一次,如果是一个新项目,我会建议你使用facelet。
请参阅教程here
https://stackoverflow.com/questions/3381237
复制相似问题