我在WebSphere Application Server 8上使用Apache MyFaces 2.1和'wicked-charts-jsf21-1.4.2.jar'和'wicked-charts-highcharts-1.4.2.jar'。 我也使用jquery-1.9.1.min.js + http://code.highcharts.com/highcharts.js。
当我从wicked-charts-snapshot实现一些示例时,我在InternetExplorer(版本8)中出现Javascript错误。
为myBean:
@ManagedBean(name = "myBean")
@SessionScoped
public class Chart {
Options options = new Options();
public Chart() {
initOptions();
}
private void initOptions() {
options.setChartOptions(new ChartOptions().setType(SeriesType.LINE));
options.setTitle(new Title("My very own chart."));
options.setxAxis(new Axis().setCategories(Arrays.asList(new String[] {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec" })));
options.setyAxis(new Axis().setTitle(new Title("Temperature (C)")));
options.setLegend(new Legend().setLayout(LegendLayout.VERTICAL)
.setAlign(HorizontalAlignment.RIGHT)
.setVerticalAlign(VerticalAlignment.TOP).setX(-10).setY(100)
.setBorderWidth(0));
options.addSeries(new SimpleSeries().setName("Tokyo").setData(
Arrays.asList(new Number[] { 7.0, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6 })));
options.addSeries(new SimpleSeries().setName("New York").setData(
Arrays.asList(new Number[] { -0.2, 0.8, 5.7, 11.3, 17.0, 22.0,
24.8, 24.1, 20.1, 14.1, 8.6, 2.5 })));
}
public Options getOptions() {
return options;
}
public void setOptions(Options options) {
this.options = options;
}
}
我的面孔文件:
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:wc="http://googlecode.com/wickedcharts"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<f:view>
<h:head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
type="text/javascript"></script>
</h:head>
<h:body>
<script src="http://code.highcharts.com/highcharts.js"
type="text/javascript"></script>
<wc:chart id="chart1" options="#{myBean.options}" />
</h:body>
</f:view>
</html>
问题是document.ready()部分(由wickedChart生成):
<script type="text/javascript">
/*<![CDATA[*/
//the following line is not supported in IE
document.addEventListener("DOMContentLoaded", function onDom(event) {
var chart1Options = {
"chart" : {
快照适用于所有浏览器,包括Internet Explorer。但快照不使用JSF,而是使用Apache Wicked。
所以有人知道这是否是一个邪恶的-jsf问题? 我怎么处理这个?